Skip to content

Commit 7c38290

Browse files
committed
Remove usage of parser module, deprecated in Python 3.9
Fix #6404
1 parent b39b867 commit 7c38290

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

changelog/6404.trivial.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove usage of ``parser`` module, deprecated in Python 3.9.

src/_pytest/_code/source.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,12 @@ def isparseable(self, deindent=True):
123123
""" return True if source is parseable, heuristically
124124
deindenting it by default.
125125
"""
126-
from parser import suite as syntax_checker
127-
128126
if deindent:
129127
source = str(self.deindent())
130128
else:
131129
source = str(self)
132130
try:
133-
# compile(source+'\n', "x", "exec")
134-
syntax_checker(source + "\n")
131+
ast.parse(source)
135132
except KeyboardInterrupt:
136133
raise
137134
except Exception:

0 commit comments

Comments
 (0)