summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_syntax.py
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2020-10-30 23:48:42 (GMT)
committerGitHub <noreply@github.com>2020-10-30 23:48:42 (GMT)
commit06f8c3328dcd81c84d1ee2b3a57b5381dcb38482 (patch)
treecc3ad1395744a8eba15c779480a9ce9276e8bc5f /Lib/test/test_syntax.py
parent6e03c0ad156797cd6e9132e895d55dac0344d340 (diff)
downloadcpython-06f8c3328dcd81c84d1ee2b3a57b5381dcb38482.zip
cpython-06f8c3328dcd81c84d1ee2b3a57b5381dcb38482.tar.gz
cpython-06f8c3328dcd81c84d1ee2b3a57b5381dcb38482.tar.bz2
bpo-42214: Fix check for NOTEQUAL token in the PEG parser for the barry_as_flufl rule (GH-23048)
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r--Lib/test/test_syntax.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index c25b852..e89d940 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -955,6 +955,23 @@ pass
code += f"{' '*4*12}pass"
self._check_error(code, "too many statically nested blocks")
+ 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