From e911f2dc5e88b37d83569ba97fd3f52d26dddb78 Mon Sep 17 00:00:00 2001 From: Batuhan Taskaya Date: Sat, 31 Oct 2020 15:06:16 +0300 Subject: [PATCH] bpo-42218: Check for the error indicator when expecting a new token --- Lib/test/test_syntax.py | 3 +++ Parser/pegen.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index e89d9401f2c397f..9abb545c0ad7900 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -972,6 +972,9 @@ def func2(): """ self._check_error(code, "invalid syntax") + def test_unexpected_line_continuation(self): + self._check_error('A.\u018a\\ ', "unexpected character after line continuation character") + def test_main(): support.run_unittest(SyntaxTestCase) from test import test_syntax diff --git a/Parser/pegen.c b/Parser/pegen.c index 188fd282b760436..be6441e6f70d4d1 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -835,7 +835,7 @@ expr_ty _PyPegen_name_token(Parser *p) { Token *t = _PyPegen_expect_token(p, NAME); - if (t == NULL) { + if (t == NULL || p->error_indicator) { return NULL; } char* s = PyBytes_AsString(t->bytes);