Skip to content

Commit ed2793b

Browse files
Update Lib/test/test_exceptions.py
Co-authored-by: Peter Bierma <[email protected]>
1 parent 09a19c2 commit ed2793b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Lib/test/test_exceptions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,13 @@ def test_keyerror_context(self):
19201920
@unittest.skipIf(support.Py_TRACE_REFS, 'cannot test Py_TRACE_REFS build')
19211921
def test_exec_set_nomemory_hang(self):
19221922
import_module("_testcapi")
1923+
# gh-134163: A MemoryError inside code that was wrapped by a try/except
1924+
# block would lead to an infinite loop.
1925+
1926+
# The frame_lasti needs to be greater than 257 to prevent
1927+
# PyLong_FromLong() from returning cached integers, which
1928+
# don't require a memory allocation. Prepend some dummy code
1929+
# to artificially increase the instruction index.
19231930
warmup_code = "a = list(range(0, 1))\n" * 20
19241931
user_input = warmup_code + dedent("""
19251932
try:

0 commit comments

Comments
 (0)