diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-07-05 01:32:54 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-07-05 01:32:54 +0900 |
commit | ec3754bd94eaa3aa3c5410ee6ab100bb27bfb798 (patch) | |
tree | d0446a967a4f8cbc3208d48d6bf3d9b7c90ca25e /sphinx/util/pycompat.py | |
parent | b268963709dc9256cf711d4cc054a86e70226702 (diff) | |
parent | 9fd9edebb47a3a5eda8c6065b12b71cdb0985a73 (diff) | |
download | sphinx-git-ec3754bd94eaa3aa3c5410ee6ab100bb27bfb798.tar.gz |
Merge branch '3.x'
Diffstat (limited to 'sphinx/util/pycompat.py')
-rw-r--r-- | sphinx/util/pycompat.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sphinx/util/pycompat.py b/sphinx/util/pycompat.py index 7d22a792a..5aeb0f9cc 100644 --- a/sphinx/util/pycompat.py +++ b/sphinx/util/pycompat.py @@ -26,11 +26,11 @@ def convert_with_2to3(filepath: str) -> str: try: from lib2to3.refactor import RefactoringTool, get_fixers_from_package from lib2to3.pgen2.parse import ParseError - except ImportError: + except ImportError as exc: # python 3.9.0a6+ emits PendingDeprecationWarning for lib2to3. # Additionally, removal of the module is still discussed at PEP-594. # To support future python, this catches ImportError for lib2to3. - raise SyntaxError + raise SyntaxError from exc fixers = get_fixers_from_package('lib2to3.fixes') refactoring_tool = RefactoringTool(fixers) @@ -41,7 +41,8 @@ def convert_with_2to3(filepath: str) -> str: # do not propagate lib2to3 exceptions lineno, offset = err.context[1] # try to match ParseError details with SyntaxError details - raise SyntaxError(err.msg, (filepath, lineno, offset, err.value)) + + raise SyntaxError(err.msg, (filepath, lineno, offset, err.value)) from err return str(tree) |