mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.10] bpo-46110: Add a recursion check to avoid stack overflow in the PEG parser (GH-30177) (GH-30214)
Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>.
(cherry picked from commit e9898bf153)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
This commit is contained in:
parent
95948169d7
commit
dc73199a21
5 changed files with 4424 additions and 3073 deletions
|
|
@ -1576,6 +1576,14 @@ def test_syntax_error_on_deeply_nested_blocks(self):
|
|||
"""
|
||||
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 test_main():
|
||||
support.run_unittest(SyntaxTestCase)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue