https://github.com/python/cpython/commit/e41677b08f2ded60572cd8baef4d719f7271ab6d
commit: e41677b08f2ded60572cd8baef4d719f7271ab6d
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-09-13T15:45:08+02:00
summary:

gh-157415: Skip @support.nomemtest if Python is built with TSAN (#157416)

There is a known data race involving PyMem_SetAllocator(). Just skip
tests using _testcapi.set_nomemory() is Python is built with the
thread sanitizer.

Mark test_io.test_memoryio test using _testcapi.set_nomemory()
with @support.nomemtest.

files:
M Lib/test/support/__init__.py
M Lib/test/test_io/test_memoryio.py

diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 210982fae236d5f..625898e6734aaa5 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -1373,7 +1373,11 @@ def internal(*args, **kwargs):
         import_module('_testcapi')
         return test(*args, **kwargs)
 
-    return cpython_only(internal)
+    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/Lib/test/test_io/test_memoryio.py 
b/Lib/test/test_io/test_memoryio.py
index 423b99779bc6e78..59e0dc4435d1f3b 100644
--- a/Lib/test/test_io/test_memoryio.py
+++ b/Lib/test/test_io/test_memoryio.py
@@ -754,6 +754,7 @@ def __buffer__(self, flags):
         self.assertEqual(memio.getvalue(), b"01AAA56789")
         self.assertEqual(memio.tell(), 5)
 
+    @support.nomemtest
     def test_memory_error(self):
         # gh-157242: io.BytesIO() must not close the file on MemoryError
         _testcapi = import_helper.import_module('_testcapi')

_______________________________________________
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