From ca71c2269c933ada9d13e907a597162a949cfdbc Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 17 Nov 2026 21:48:31 +0100 Subject: [PATCH] gh-162144: Skip `@nomemtest` tests when using a thread sanitizer (TSan) (GH-162154) (cherry picked from commit e28063ef9bc5c79ab8576a7293ec97e5bd62b37a) Co-authored-by: Victor Stinner --- Lib/test/support/__init__.py | 8 +++++++- .../Tests/2026-11-17-15-57-41.gh-issue-162144.pL5k29.rst | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Tests/2026-11-17-15-57-41.gh-issue-162144.pL5k29.rst diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 238316dffb2830..0a2f60ca9b4df8 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 00000000000000..bbd4a9cf54752e --- /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.