summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2020-10-31 20:31:41 +0200
committerGitHub <noreply@github.com>2020-10-31 20:31:41 +0200
commit02cdfc93f82fecdb7eae97a868d4ee222b9875d9 (patch)
tree85ec4c7f233e9bff63b0e6af21049ec00d7e0af9 /Lib/test/test_syntax.py
parentbpo-42198: Improve consistency of Union docs (GH-23029) (diff)
downloadcpython-02cdfc93f82fecdb7eae97a868d4ee222b9875d9.tar.gz
cpython-02cdfc93f82fecdb7eae97a868d4ee222b9875d9.tar.bz2
cpython-02cdfc93f82fecdb7eae97a868d4ee222b9875d9.zip
bpo-42218: Correctly handle errors in left-recursive rules (GH-23065)
Left-recursive rules need to check for errors explicitly, since even if the rule returns NULL, the parsing might continue and lead to long-distance failures. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r--Lib/test/test_syntax.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index e89d9401f2c..91ca1db43a7 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -972,6 +972,14 @@ def func2():
"""
self._check_error(code, "invalid syntax")
+ def test_invalid_line_continuation_left_recursive(self):
+ # Check bpo-42218: SyntaxErrors following left-recursive rules
+ # (t_primary_raw in this case) need to be tested explicitly
+ self._check_error("A.\u018a\\ ",
+ "unexpected character after line continuation character")
+ self._check_error("A.\u03bc\\\n",
+ "unexpected EOF while parsing")
+
def test_main():
support.run_unittest(SyntaxTestCase)
from test import test_syntax