summaryrefslogtreecommitdiff
path: root/sphinx/util/pycompat.py
diff options
context:
space:
mode:
authorRam Rachum <ram@rachum.com>2020-06-14 00:46:19 +0300
committerRam Rachum <ram@rachum.com>2020-06-14 14:37:16 +0300
commit53c1dff91c0b7100e1ce1b51acbf0fffbc10cf9c (patch)
tree93bca0f98dfcf0f83f32987f898a7fbafe8f25dd /sphinx/util/pycompat.py
parent0fc97a0b56d31f2703ff42dfe946e8d11d667909 (diff)
downloadsphinx-git-53c1dff91c0b7100e1ce1b51acbf0fffbc10cf9c.tar.gz
Fix exception causes all over the codebase
Diffstat (limited to 'sphinx/util/pycompat.py')
-rw-r--r--sphinx/util/pycompat.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/sphinx/util/pycompat.py b/sphinx/util/pycompat.py
index 664387cac..2173fce14 100644
--- a/sphinx/util/pycompat.py
+++ b/sphinx/util/pycompat.py
@@ -34,11 +34,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)
@@ -49,7 +49,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)