-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
[3.13] gh-134163: fix: exec('_testcapi.set_nomemory(0)') hang in new repl 3.13 #138491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
1202ec6
4cd38e8
e557017
53f713c
9cc89f1
a9b6f96
66ec42e
a9e6b64
791ca86
4827680
8ec5769
edcfff7
81c6244
847bd7b
ff3c7f4
175a13e
d952d53
5fa3a1b
d3274fb
c89c5b5
63a6b7d
977703f
095f865
932c15e
52310f0
bb790af
06b779a
30cd34d
26ce31b
5ab08c7
789040c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,45 @@ def test_no_memory(self): | |
# Exit code 120: Py_FinalizeEx() failed to flush stdout and stderr. | ||
self.assertIn(p.returncode, (1, 120)) | ||
|
||
@cpython_only | ||
def test_exec_set_nomemory_hang(self): | ||
# gh-134163 Test case that triggers no memory hang condition | ||
yihong0618 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
user_input = dedent(""" | ||
a1 = list(range(1000, 2000)) | ||
yihong0618 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
a2 = list(range(1000, 2000)) | ||
a3 = list(range(1000, 2000)) | ||
a4 = list(range(1000, 2000)) | ||
a5 = list(range(1000, 2000)) | ||
a6 = list(range(1000, 2000)) | ||
a7 = list(range(1000, 2000)) | ||
a8 = list(range(1000, 2000)) | ||
a9 = list(range(1000, 2000)) | ||
a10 = list(range(1000, 2000)) | ||
a11 = list(range(1000, 2000)) | ||
a12 = list(range(1000, 2000)) | ||
a13 = list(range(1000, 2000)) | ||
a14 = list(range(1000, 2000)) | ||
try: | ||
import _testcapi | ||
_testcapi.set_nomemory(0) | ||
b = list(range(1000, 2000)) | ||
except Exception as e: | ||
import traceback | ||
traceback.print_exc() | ||
""") | ||
p = spawn_repl() | ||
with SuppressCrashReport(): | ||
p.stdin.write(user_input) | ||
|
||
output = kill_python(p) | ||
yihong0618 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
self.assertIn(p.returncode, (0, 1, 120)) | ||
yihong0618 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
# The key test is that it doesn't hang - if we get output, the test passed | ||
# Look for either successful execution or memory error indicators | ||
has_traceback = "Traceback" in output | ||
has_memory_error = "MemoryError" in output | ||
yihong0618 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
# Either we get a traceback (expected) or we complete without hanging | ||
self.assertTrue(len(output) > 0, f"Expected some output, got: {output}") # At minimum, should not hang | ||
yihong0618 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
@cpython_only | ||
def test_multiline_string_parsing(self): | ||
# bpo-39209: Multiline string tokens need to be handled in the tokenizer | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fix in default repl exec('_testcapi.set_nomemory(0)') hang forever. | ||
yihong0618 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.