[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 06f8c3328d)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
This commit is contained in:
Pablo Galindo 2020-10-31 00:40:42 +00:00 committed by GitHub
parent 09c6120be8
commit ddcd57e3ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 5 deletions

View file

@ -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