Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Lib/test/test_fstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,19 @@ def test_concat_decode_failure_does_not_crash(self):
'''
assert_python_ok('-c', script)

def test_memoryerror_during_concat_does_not_crash(self):
# gh-153182: Recursion/Memory errors parsing f-strings should be properly unwound
# and the parser should not attempt to continue parsing after the error. (In this case,
# a SyntaxWarning will subsequently be raised for the invalid escape, triggering a debug assert
# from the existing Exception)
script = r'''
try:
compile('(x""f"\\{0}"<' * 1276, "<test>", "exec")
except MemoryError:
pass
'''
assert_python_ok('-c', script)

def test_literal(self):
self.assertEqual(f'', '')
self.assertEqual(f'a', 'a')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix an issue where some grammar rules tried to continue parsing after an
error
Loading
Loading