File tree Expand file tree Collapse file tree
Tools/peg_generator/pegen Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -911,6 +911,31 @@ def unused_code_at_end():
911911 'RETURN_VALUE' ,
912912 list (dis .get_instructions (unused_code_at_end ))[- 1 ].opname )
913913
914+ # This is a regression test for CPython bug
915+ # where SystemError was thrown, instead of a MemoryError or Syntax Error
916+ # when compiling python code, generated by a fuzzer
917+ @support .cpython_only
918+ def test_parser_stack_overflow_no_crash (self ):
919+ string = (
920+ b'(*h(((h(h(h(' +
921+ b'[' * 35 +
922+ b'*h(' +
923+ b'[' * 38 +
924+ b'**h(' +
925+ b'[' * 31 +
926+ b'(' * 4 +
927+ b'~' * 20 +
928+ b'F{' +
929+ b'[' * 27 +
930+ b'**h(' +
931+ b'[' * 31 +
932+ b'(' * 4 +
933+ b'~' * 23 +
934+ b'F{F"{F"{F"{F"{F"{F"{F"{FF""{{F"{""{F"{F{{F"{F"{F"\\ }'
935+ )
936+ with self .assertRaises ((MemoryError , SyntaxError )):
937+ compile (string , '<input>' , "single" )
938+
914939 @support .cpython_only
915940 def test_docstring (self ):
916941 src = textwrap .dedent ("""
You can’t perform that action at this time.
0 commit comments