Content-Length: 3448 | pFad | http://github.com/python/pythoncapi-compat/pull/166.patch
69D188B2
From b4a0a0b24631da41323418188fd07dcac3724e84 Mon Sep 17 00:00:00 2001
From: Victor Stinner
Date: Thu, 12 Feb 2026 15:26:36 +0100
Subject: [PATCH 1/2] Fix tests on python3.14t
* Add Py_MOD_GIL_NOT_USED to the C/C++ extension.
* Add "t" suffix to the Python version on free-threaded build.
* On Python 3.14 and newer, tests call sys._clear_internal_caches()
instead of sys._clear_type_cache() to avoid a deprecation warning.
---
tests/test_pythoncapi_compat.py | 17 +++++++++++++++--
tests/test_pythoncapi_compat_cext.c | 3 +++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/tests/test_pythoncapi_compat.py b/tests/test_pythoncapi_compat.py
index 8480415..f7a258b 100644
--- a/tests/test_pythoncapi_compat.py
+++ b/tests/test_pythoncapi_compat.py
@@ -19,6 +19,11 @@
except ImportError:
# Python 2
faulthandler = None
+try:
+ import sysconfig
+except ImportError:
+ # Python 3.1 and older
+ sysconfig = None
# test.utils
from utils import run_command, command_stdout
@@ -94,10 +99,13 @@ def _run_tests(tests, verbose):
test_func()
+_HAS_CLEAR_INTERNAL_CACHES = hasattr(sys, '_clear_internal_caches')
_HAS_CLEAR_TYPE_CACHE = hasattr(sys, '_clear_type_cache')
def _refleak_cleanup():
- if _HAS_CLEAR_TYPE_CACHE:
+ if _HAS_CLEAR_INTERNAL_CACHES:
+ sys._clear_internal_caches()
+ elif _HAS_CLEAR_TYPE_CACHE:
sys._clear_type_cache()
gc.collect()
@@ -134,7 +142,12 @@ def python_version():
python_impl = "PyPy"
else:
python_impl = 'Python'
- return "%s %s.%s (%s build)" % (python_impl, ver.major, ver.minor, build)
+ pyver = "%s.%s" % (ver.major, ver.minor)
+ if ver >= (3, 13):
+ if sysconfig.get_config_var('Py_GIL_DISABLED'):
+ # Free-threaded build
+ pyver += "t"
+ return "%s %s (%s build)" % (python_impl, pyver, build)
def run_tests(module_name, lang):
diff --git a/tests/test_pythoncapi_compat_cext.c b/tests/test_pythoncapi_compat_cext.c
index 6fd60b2..132708d 100644
--- a/tests/test_pythoncapi_compat_cext.c
+++ b/tests/test_pythoncapi_compat_cext.c
@@ -2624,6 +2624,9 @@ module_exec(PyObject *module)
#if PY_VERSION_HEX >= 0x03050000
static PyModuleDef_Slot module_slots[] = {
{Py_mod_exec, _Py_CAST(void*, module_exec)},
+#if PY_VERSION_HEX >= 0x030D0000
+ {Py_mod_gil, Py_MOD_GIL_NOT_USED},
+#endif
{0, _Py_NULL}
};
#endif
From 3f7c03bfbac4d8bd2405acf843482c9f314aa639 Mon Sep 17 00:00:00 2001
From: Victor Stinner
Date: Thu, 12 Feb 2026 15:40:36 +0100
Subject: [PATCH 2/2] Reuse python_version() in display_title()
---
tests/test_pythoncapi_compat.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tests/test_pythoncapi_compat.py b/tests/test_pythoncapi_compat.py
index f7a258b..47ffd9b 100644
--- a/tests/test_pythoncapi_compat.py
+++ b/tests/test_pythoncapi_compat.py
@@ -54,9 +54,7 @@ def display_title(title):
if not VERBOSE:
return
- ver = sys.version_info
- title = "Python %s.%s: %s" % (ver.major, ver.minor, title)
-
+ title = "%s: %s" % (python_version(), title)
print(title)
print("=" * len(title))
print()
@@ -151,6 +149,9 @@ def python_version():
def run_tests(module_name, lang):
+ if VERBOSE:
+ print("")
+
title = "Test %s (%s)" % (module_name, lang)
display_title(title)
--- a PPN by Garber Painting Akron. With Image Size Reduction included!Fetched URL: http://github.com/python/pythoncapi-compat/pull/166.patch
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy