https://github.com/python/cpython/commit/1818fba7e737320b4241fdde095146a4c52c0e63 commit: 1818fba7e737320b4241fdde095146a4c52c0e63 branch: main author: Victor Stinner <[email protected]> committer: vstinner <[email protected]> date: 2026-10-06T23:03:46+02:00 summary:
Use _testlimitedcapi in test_free_threading.test_capi (#158935) Replace ctypes with _testlimitedcapi. ctypes is not always available, and _testlimitedcapi is a thin wrapper to the C API. Skip the test if _testlimitedcapi is missing. files: M Lib/test/test_free_threading/test_capi.py diff --git a/Lib/test/test_free_threading/test_capi.py b/Lib/test/test_free_threading/test_capi.py index b0be94629af009..36021eb33d5900 100644 --- a/Lib/test/test_free_threading/test_capi.py +++ b/Lib/test/test_free_threading/test_capi.py @@ -1,14 +1,12 @@ -import ctypes.util import sys import unittest +from test.support import import_helper from test.support import threading_helper from test.support.threading_helper import run_concurrently - [email protected]_dll_function(ctypes.pythonapi) -def PyImport_AddModuleRef(name: ctypes.c_char_p) -> ctypes.py_object: - pass +# Skip the test if the extension is missing +_testlimitedcapi = import_helper.import_module('_testlimitedcapi') @threading_helper.requires_working_threading() @@ -20,6 +18,7 @@ def test_pyimport_addmoduleref_thread_safe(self): NUM_ITERS = 10 NTHREADS = 4 + PyImport_AddModuleRef = _testlimitedcapi.PyImport_AddModuleRef module_name = f"test_free_threading_addmoduleref_{id(self)}" module_name_bytes = module_name.encode() sys.modules.pop(module_name, None) _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
