https://github.com/python/cpython/commit/ee7f7927b60ae43d7590d6cc1ebdcdb2a8b4c653
commit: ee7f7927b60ae43d7590d6cc1ebdcdb2a8b4c653
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: vstinner <[email protected]>
date: 2026-11-17T21:27:05Z
summary:

[3.14] gh-162144: Skip `@nomemtest` tests when using a thread sanitizer (TSan) 
(GH-162154) (#162175)

gh-162144: Skip `@nomemtest` tests when using a thread sanitizer (TSan) 
(GH-162154)
(cherry picked from commit e28063ef9bc5c79ab8576a7293ec97e5bd62b37a)

Co-authored-by: Victor Stinner <[email protected]>

files:
A Misc/NEWS.d/next/Tests/2026-11-17-15-57-41.gh-issue-162144.pL5k29.rst
M Lib/test/support/__init__.py

diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 238316dffb28301..0a2f60ca9b4df86 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -1242,7 +1242,13 @@ def internal(*args, **kwargs):
         import_module('_testcapi')
         return test(*args, **kwargs)
 
-    return cpython_only(internal)
+    # gh-162144: set_nomemory() and call_with_nomemory() of _testcapi are not
+    # thread safe and emit warnings when using a thread sanitizer (TSan).
+    use_tsan = check_sanitizer(thread=True)
+    reason ='not working with thread sanitizer (gh-157415)'
+    skip_if_tsan = unittest.skipIf(use_tsan, reason)
+
+    return cpython_only(skip_if_tsan(internal))
 
 def bigaddrspacetest(f):
     """Decorator for tests that fill the address space."""
diff --git 
a/Misc/NEWS.d/next/Tests/2026-11-17-15-57-41.gh-issue-162144.pL5k29.rst 
b/Misc/NEWS.d/next/Tests/2026-11-17-15-57-41.gh-issue-162144.pL5k29.rst
new file mode 100644
index 000000000000000..bbd4a9cf54752e0
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2026-11-17-15-57-41.gh-issue-162144.pL5k29.rst
@@ -0,0 +1,3 @@
+Skip ``@support.nomemtest`` tests when using a thread sanitizer (TSan).
+``set_nomemory()`` and ``call_with_nomemory()`` functions of the
+:mod:`!_testcapi` extension are not thread safe. Patch by Victor Stinner.

_______________________________________________
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]

Reply via email to