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 b39b867967
commit 24898e0640
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 """ return True if source is parseable, heuristically
deindenting it by default. deindenting it by default.
""" """
from parser import suite as syntax_checker
if deindent: if deindent:
source = str(self.deindent()) source = str(self.deindent())
else: else:
source = str(self) source = str(self)
try: try:
# compile(source+'\n', "x", "exec") ast.parse(source)
syntax_checker(source + "\n") except (SyntaxError, ValueError, TypeError):
except KeyboardInterrupt:
raise
except Exception:
return False return False
else: else:
return True return True