]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-112388: Fix an error that was causing the parser to try to overwrite tokenizer...
authorPablo Galindo Salgado <Pablogsal@gmail.com>
Mon, 27 Nov 2023 18:36:11 +0000 (18:36 +0000)
committerGitHub <noreply@github.com>
Mon, 27 Nov 2023 18:36:11 +0000 (18:36 +0000)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Lib/test/test_syntax.py
Misc/NEWS.d/next/Core and Builtins/2023-11-25-22-58-49.gh-issue-112388.MU3cIM.rst [new file with mode: 0644]
Parser/pegen_errors.c

index f6fa6495508d2c41db387444a6e0c6ed09c7c5ca..e80e95383b897d2fca8f7d9c889700f45f127cbd 100644 (file)
@@ -2349,6 +2349,7 @@ func(
 
     def test_invisible_characters(self):
         self._check_error('print\x17("Hello")', "invalid non-printable character")
+        self._check_error(b"with(0,,):\n\x01", "invalid non-printable character")
 
     def test_match_call_does_not_raise_syntax_error(self):
         code = """
diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-11-25-22-58-49.gh-issue-112388.MU3cIM.rst b/Misc/NEWS.d/next/Core and Builtins/2023-11-25-22-58-49.gh-issue-112388.MU3cIM.rst
new file mode 100644 (file)
index 0000000..1c82be2
--- /dev/null
@@ -0,0 +1,2 @@
+Fix an error that was causing the parser to try to overwrite tokenizer
+errors. Patch by pablo Galindo
index e2bc3b91c80718856657ab1539e1228f1da748c4..2528d4502b3c0c7a7e74ba4eab8e9853ea06b7ee 100644 (file)
@@ -219,6 +219,10 @@ exit:
 void *
 _PyPegen_raise_error(Parser *p, PyObject *errtype, int use_mark, const char *errmsg, ...)
 {
+    // Bail out if we already have an error set.
+    if (p->error_indicator && PyErr_Occurred()) {
+        return NULL;
+    }
     if (p->fill == 0) {
         va_list va;
         va_start(va, errmsg);