diff options
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r-- | Lib/test/test_syntax.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index ac5a41c..09c0d56 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -1617,6 +1617,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 test_main(): support.run_unittest(SyntaxTestCase) |