mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-46110: Add a recursion check to avoid stack overflow in the PEG parser (GH-30177)
Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
This commit is contained in:
parent
6ca78affc8
commit
e9898bf153
5 changed files with 4602 additions and 3197 deletions
|
@ -1729,6 +1729,14 @@ while 1:
|
|||
"""
|
||||
self._check_error(source, "too many statically nested blocks")
|
||||
|
||||
@support.cpython_only
|
||||
def test_error_on_parser_stack_overflow(self):
|
||||
source = "-" * 100000 + "4"
|
||||
for mode in ["exec", "eval", "single"]:
|
||||
with self.subTest(mode=mode):
|
||||
with self.assertRaises(MemoryError):
|
||||
compile(source, "<string>", mode)
|
||||
|
||||
|
||||
def load_tests(loader, tests, pattern):
|
||||
tests.addTest(doctest.DocTestSuite())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue