mirror of
https://github.com/python/cpython.git
synced 2025-08-23 02:04:56 +00:00
bpo-46707: Avoid potential exponential backtracking in some syntax errors (GH-31241)
This commit is contained in:
parent
cb68788dca
commit
b71dc71905
4 changed files with 1561 additions and 1544 deletions
|
@ -1770,6 +1770,14 @@ while 1:
|
|||
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 load_tests(loader, tests, pattern):
|
||||
tests.addTest(doctest.DocTestSuite())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue