Skip to content

Commit

Permalink
Fix test_list.ListTest.test_no_memory under trace refs build
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mpage committed Mar 6, 2025
1 parent 9c69150 commit c7e9b70
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Lib/test/test_list.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import signal
import sys
import textwrap
from test import list_tests, support
Expand Down Expand Up @@ -324,8 +325,12 @@ def test_no_memory(self):
_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()

0 comments on commit c7e9b70

Please sign in to comment.