diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2020-10-31 00:40:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-31 00:40:42 (GMT) |
commit | ddcd57e3ea75ab0ad370bbaaa6b76338edbca395 (patch) | |
tree | ad2dc28a4ee0ccb922517d4af8a868a3ce19d08a /Lib/test/test_syntax.py | |
parent | 09c6120be8c70366495b027ae3daa213609de3ed (diff) | |
download | cpython-ddcd57e3ea75ab0ad370bbaaa6b76338edbca395.zip cpython-ddcd57e3ea75ab0ad370bbaaa6b76338edbca395.tar.gz cpython-ddcd57e3ea75ab0ad370bbaaa6b76338edbca395.tar.bz2 |
[3.9] bpo-42214: Fix check for NOTEQUAL token in the PEG parser for the barry_as_flufl rule (GH-23048) (GH-23051)
(cherry picked from commit 06f8c3328dcd81c84d1ee2b3a57b5381dcb38482)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r-- | Lib/test/test_syntax.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index b0527e6..a95992d 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -947,6 +947,23 @@ pass self.fail("Empty line after a line continuation character is valid.") + def test_barry_as_flufl_with_syntax_errors(self): + # The "barry_as_flufl" rule can produce some "bugs-at-a-distance" if + # is reading the wrong token in the presence of syntax errors later + # in the file. See bpo-42214 for more information. + code = """ +def func1(): + if a != b: + raise ValueError + +def func2(): + try + return 1 + finally: + pass +""" + self._check_error(code, "invalid syntax") + def test_main(): support.run_unittest(SyntaxTestCase) from test import test_syntax |