]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-118331: Fix `test_list.ListTest.test_no_memory` under trace refs build (#130921)
authormpage <mpage@meta.com>
Thu, 6 Mar 2025 20:11:50 +0000 (12:11 -0800)
committerGitHub <noreply@github.com>
Thu, 6 Mar 2025 20:11:50 +0000 (12:11 -0800)
Fix `test_list.ListTest.test_no_memory` under trace refs build

Memory allocation ends up failing in _PyRefchainTrace(), which produces
different output. Assert that we don't segfault, which is the thing
we want to test and is less brittle than checking output.

Lib/test/test_list.py

index 2a34fd04f35059d796e5de2cd1636ac9598d38d7..725e07f3ad023fd98dafe38b7c0da9c18ee77eee 100644 (file)
@@ -1,3 +1,4 @@
+import signal
 import sys
 import textwrap
 from test import list_tests, support
@@ -324,8 +325,12 @@ class ListTest(list_tests.CommonTest):
         _testcapi.set_nomemory(0)
         l = [None]
         """)
-        _, _, err = assert_python_failure("-c", code)
-        self.assertIn("MemoryError", err.decode("utf-8"))
+        rc, _, _ = assert_python_failure("-c", code)
+        if support.MS_WINDOWS:
+            # STATUS_ACCESS_VIOLATION
+            self.assertNotEqual(rc, 0xC0000005)
+        else:
+            self.assertNotEqual(rc, -int(signal.SIGSEGV))
 
 if __name__ == "__main__":
     unittest.main()