Python 3.11 fixes

This commit is contained in:
Miro Hrončok 2022-07-07 02:17:11 +02:00
parent 87abc98709
commit 7b990a70c4
3 changed files with 80 additions and 0 deletions

34
6d1d17d016.patch Normal file
View File

@ -0,0 +1,34 @@
From 6d1d17d016d092146b620e4f9338f9b125e33ded Mon Sep 17 00:00:00 2001
From: Florian Bruhin <me@the-compiler.org>
Date: Tue, 26 Apr 2022 11:16:27 +0200
Subject: [PATCH] Adjust imports of deprecated sre_* modules in Python 3.11
Fixes #3309
See https://github.com/python/cpython/issues/91308
I don't see a way to avoid relying on Python 3.11 internals here, so
this instead just adjusts the imports to avoid deprecation warnings.
---
.../src/hypothesis/strategies/_internal/regex.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/hypothesis-python/src/hypothesis/strategies/_internal/regex.py b/hypothesis-python/src/hypothesis/strategies/_internal/regex.py
index 5da2b3ba2d..b93e8d192b 100644
--- a/hypothesis-python/src/hypothesis/strategies/_internal/regex.py
+++ b/hypothesis-python/src/hypothesis/strategies/_internal/regex.py
@@ -10,8 +10,13 @@
import operator
import re
-import sre_constants as sre
-import sre_parse
+
+try: # pragma: no cover
+ import re._constants as sre
+ import re._parser as sre_parse
+except ImportError: # Python < 3.11
+ import sre_constants as sre # type: ignore
+ import sre_parse # type: ignore
from hypothesis import reject, strategies as st
from hypothesis.internal.charmap import as_general_categories, categories

42
a4681f6962.patch Normal file
View File

@ -0,0 +1,42 @@
From a4681f6962ea137db3eec059fb453929eb998fec Mon Sep 17 00:00:00 2001
From: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
Date: Sat, 7 May 2022 23:45:33 -0600
Subject: [PATCH] Tests work on 3.11.0b1
Thanks to CPython upstream fixes, these tests should now just work
---
hypothesis-python/tests/conftest.py | 5 -----
hypothesis-python/tests/cover/test_lookup_py37.py | 4 ----
2 files changed, 9 deletions(-)
diff --git a/hypothesis-python/tests/conftest.py b/hypothesis-python/tests/conftest.py
index 988efaf70c..bcbd024903 100644
--- a/hypothesis-python/tests/conftest.py
+++ b/hypothesis-python/tests/conftest.py
@@ -37,11 +37,6 @@
if sys.version_info >= (3, 11):
collect_ignore_glob.append("cover/test_asyncio.py") # @asyncio.coroutine removed
- assert sys.version_info.releaselevel == "alpha"
- # TODO: our traceback elision doesn't work with Python 3.11's nice new format yet
- collect_ignore_glob.append("cover/test_traceback_elision.py")
- collect_ignore_glob.append("pytest/test_capture.py")
-
def pytest_configure(config):
config.addinivalue_line("markers", "slow: pandas expects this marker to exist.")
diff --git a/hypothesis-python/tests/cover/test_lookup_py37.py b/hypothesis-python/tests/cover/test_lookup_py37.py
index bdfbbecd9e..6a1955eb6b 100644
--- a/hypothesis-python/tests/cover/test_lookup_py37.py
+++ b/hypothesis-python/tests/cover/test_lookup_py37.py
@@ -163,10 +163,6 @@ def test_resolving_standard_callable_ellipsis(x: collections.abc.Callable[..., E
assert isinstance(x(1, 2, 3, a=4, b=5, c=6), Elem)
-@pytest.mark.skipif(
- sys.version_info[:3] == (3, 11, 0),
- reason="https://github.com/python/cpython/issues/91621",
-)
@given(...)
def test_resolving_standard_callable_no_args(x: collections.abc.Callable[[], Elem]):
assert isinstance(x, collections.abc.Callable)

View File

@ -17,6 +17,10 @@ License: MPLv2.0
URL: https://github.com/HypothesisWorks/hypothesis
Source0: %{url}/archive/hypothesis-python-%{version}/hypothesis-%{version}.tar.gz
# Python 3.11 fixes
Patch: https://github.com/HypothesisWorks/hypothesis/commit/6d1d17d016.patch
Patch: https://github.com/HypothesisWorks/hypothesis/commit/a4681f6962.patch
BuildArch: noarch
BuildRequires: python%{python3_pkgversion}-devel