[4.6] Remove usage of parser module, deprecated in Python 3.9 (#6408)

[4.6] Remove usage of parser module, deprecated in Python 3.9
This commit is contained in:
Bruno Oliveira 2020-01-06 13:07:40 -03:00 committed by GitHub
commit f606fef19d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View File

@ -0,0 +1 @@
Remove usage of ``parser`` module, deprecated in Python 3.9.

View File

@ -123,18 +123,13 @@ class Source(object):
""" return True if source is parseable, heuristically
deindenting it by default.
"""
from parser import suite as syntax_checker
if deindent:
source = str(self.deindent())
else:
source = str(self)
try:
# compile(source+'\n', "x", "exec")
syntax_checker(source + "\n")
except KeyboardInterrupt:
raise
except Exception:
ast.parse(source)
except (SyntaxError, ValueError, TypeError):
return False
else:
return True