diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-05-04 02:02:48 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-05-04 02:02:48 +0900 |
commit | 1c33824aeabb32657331ec259b07bcaf6971783a (patch) | |
tree | 48ba09c2b3295255da03c9ba4c6032f023270fc7 /sphinx/util/pycompat.py | |
parent | 75203967d802c1660c45362b5a80b76a4daabd8a (diff) | |
parent | c13ecd243709d1e210a030be5aa09b7714e35730 (diff) | |
download | sphinx-git-1c33824aeabb32657331ec259b07bcaf6971783a.tar.gz |
Merge branch '3.x'
Diffstat (limited to 'sphinx/util/pycompat.py')
-rw-r--r-- | sphinx/util/pycompat.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sphinx/util/pycompat.py b/sphinx/util/pycompat.py index bcd90a718..7d22a792a 100644 --- a/sphinx/util/pycompat.py +++ b/sphinx/util/pycompat.py @@ -23,8 +23,15 @@ def convert_with_2to3(filepath: str) -> str: warnings.warn('convert_with_2to3() is deprecated', RemovedInSphinx60Warning, stacklevel=2) - from lib2to3.refactor import RefactoringTool, get_fixers_from_package - from lib2to3.pgen2.parse import ParseError + try: + from lib2to3.refactor import RefactoringTool, get_fixers_from_package + from lib2to3.pgen2.parse import ParseError + except ImportError: + # 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 + fixers = get_fixers_from_package('lib2to3.fixes') refactoring_tool = RefactoringTool(fixers) source = refactoring_tool._read_python_source(filepath)[0] |