From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 27 Nov 2023 19:02:57 +0000 (+0100) Subject: [3.12] gh-112388: Fix an error that was causing the parser to try to overwrite tokeni... X-Git-Tag: v3.12.1~81 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=698b4b73bc2f6d2de96dac04df5102ac468e02c0;p=thirdparty%2FPython%2Fcpython.git [3.12] gh-112388: Fix an error that was causing the parser to try to overwrite tokenizer errors (GH-112410) (#112466) gh-112388: Fix an error that was causing the parser to try to overwrite tokenizer errors (GH-112410) (cherry picked from commit 2c8b19174274c183eb652932871f60570123fe99) Signed-off-by: Pablo Galindo Co-authored-by: Pablo Galindo Salgado --- diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index 5183aaa506f8..3005d0547fec 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -2309,6 +2309,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 index 000000000000..1c82be2febda --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-11-25-22-58-49.gh-issue-112388.MU3cIM.rst @@ -0,0 +1,2 @@ +Fix an error that was causing the parser to try to overwrite tokenizer +errors. Patch by pablo Galindo diff --git a/Parser/pegen_errors.c b/Parser/pegen_errors.c index e832422ab1c8..c13ba97a2480 100644 --- a/Parser/pegen_errors.c +++ b/Parser/pegen_errors.c @@ -217,6 +217,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);