Skip to content

Commit 789040c

Browse files
Apply suggestions from code review
Co-authored-by: Peter Bierma <[email protected]>
1 parent 5ab08c7 commit 789040c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Lib/test/test_exceptions.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,11 +1849,13 @@ def test_memory_error_in_subinterp(self):
18491849
@unittest.skipIf(support.Py_TRACE_REFS, 'cannot test Py_TRACE_REFS build')
18501850
def test_exec_set_nomemory_hang(self):
18511851
import_module("_testcapi")
1852-
# gh-134163: Test case that triggers no memory hang condition
1853-
# The frame_lasti need to upper 257,
1854-
# because when calling PyLong_FromLong, malloc is not invoked,
1855-
# so no MemError is triggered
1856-
# we need to warm up the memory to reproduce the issue
1852+
# gh-134163: A MemoryError inside code that was wrapped by a try/except
1853+
# block would lead to an infinite loop.
1854+
1855+
# The frame_lasti needs to be greater than 257 to prevent
1856+
# PyLong_FromLong() from returning cached integers, which
1857+
# don't require a memory allocation. Prepend some dummy code
1858+
# to artificially increase the instruction index.
18571859
warmup_code = "a = list(range(0, 1))\n" * 20
18581860
user_input = warmup_code + dedent("""
18591861
try:

0 commit comments

Comments
 (0)