Remove usage of parser module, deprecated in Python 3.9

Fix #6404
This commit is contained in:
Bruno Oliveira 2020-01-05 14:15:51 -03:00 committed by Bruno Oliveira
parent 12f74a28fa
commit 91a96ec3d6
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

@ -140,18 +140,13 @@ class Source:
""" 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