diff --git a/f606fef19d035719be6ed862f7f426a0e7c582e1.patch b/f606fef19d035719be6ed862f7f426a0e7c582e1.patch new file mode 100644 index 0000000..7b106df --- /dev/null +++ b/f606fef19d035719be6ed862f7f426a0e7c582e1.patch @@ -0,0 +1,44 @@ +From 24898e06404fdade3c37c9229402ea817d068e75 Mon Sep 17 00:00:00 2001 +From: Bruno Oliveira +Date: Sun, 5 Jan 2020 14:15:51 -0300 +Subject: [PATCH] Remove usage of parser module, deprecated in Python 3.9 + +Fix #6404 +--- + changelog/6404.trivial.rst | 1 + + src/_pytest/_code/source.py | 9 ++------- + 2 files changed, 3 insertions(+), 7 deletions(-) + create mode 100644 changelog/6404.trivial.rst + +diff --git a/changelog/6404.trivial.rst b/changelog/6404.trivial.rst +new file mode 100644 +index 0000000000..8252098b6a +--- /dev/null ++++ b/changelog/6404.trivial.rst +@@ -0,0 +1 @@ ++Remove usage of ``parser`` module, deprecated in Python 3.9. +diff --git a/src/_pytest/_code/source.py b/src/_pytest/_code/source.py +index c8a4b6adf3..b35e97b9ce 100644 +--- a/src/_pytest/_code/source.py ++++ b/src/_pytest/_code/source.py +@@ -123,18 +123,13 @@ def isparseable(self, deindent=True): + """ 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 diff --git a/pytest.spec b/pytest.spec index e547f97..3dc7d6f 100644 --- a/pytest.spec +++ b/pytest.spec @@ -6,6 +6,9 @@ License: MIT URL: https://pytest.org Source0: %{pypi_source} +# Remove usage of parser module, deprecated in Python 3.9 +Patch1: https://github.com/pytest-dev/pytest/commit/f606fef19d035719be6ed862f7f426a0e7c582e1.patch + # The test in this specfile use pytest-timeout # When building pytest for the first time with new Python version # that is not possible as it depends on pytest