diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2022-02-10 03:54:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-10 03:54:47 (GMT) |
commit | 9b23f8f78fdb0d7eba016616ae7a97abbfc65aa6 (patch) | |
tree | 43d1814ef70d514f0ac8a71b04dbeb438d306c86 /Lib/test/test_syntax.py | |
parent | 7445949a4399ab19fbdd5a0b0aca53a690c3251b (diff) | |
download | cpython-9b23f8f78fdb0d7eba016616ae7a97abbfc65aa6.zip cpython-9b23f8f78fdb0d7eba016616ae7a97abbfc65aa6.tar.gz cpython-9b23f8f78fdb0d7eba016616ae7a97abbfc65aa6.tar.bz2 |
[3.10] bpo-46707: Avoid potential exponential backtracking in some syntax errors (GH-31241). (GH-31242)
(cherry picked from commit b71dc71905ab674ccaa4a56230d17a28f61c325c)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
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) |