mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.10] bpo-46707: Avoid potential exponential backtracking in some syntax errors (GH-31241). (GH-31242)
(cherry picked from commit b71dc71905)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
This commit is contained in:
parent
7445949a43
commit
9b23f8f78f
4 changed files with 1298 additions and 1281 deletions
|
|
@ -1617,6 +1617,14 @@ def test_error_on_parser_stack_overflow(self):
|
|||
with self.assertRaises(MemoryError):
|
||||
compile(source, "<string>", mode)
|
||||
|
||||
@support.cpython_only
|
||||
def test_deep_invalid_rule(self):
|
||||
# Check that a very deep invalid rule in the PEG
|
||||
# parser doesn't have exponential backtracking.
|
||||
source = "d{{{{{{{{{{{{{{{{{{{{{{{{{```{{{{{{{ef f():y"
|
||||
with self.assertRaises(SyntaxError):
|
||||
compile(source, "<string>", "exec")
|
||||
|
||||
|
||||
def test_main():
|
||||
support.run_unittest(SyntaxTestCase)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue