Skip to content

Commit

Permalink
pythongh-112388: Fix an error that was causing the parser to try to o…
Browse files Browse the repository at this point in the history
…verwrite tokenizer errors (pythonGH-112410)

(cherry picked from commit 2c8b191)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
  • Loading branch information
pablogsal authored and miss-islington committed Nov 27, 2023
1 parent 581b244 commit 4d69501
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions Lib/test/test_syntax.py
Expand Up @@ -2152,6 +2152,7 @@ def test_error_string_literal(self):

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 = """
Expand Down
@@ -0,0 +1,2 @@
Fix an error that was causing the parser to try to overwrite tokenizer
errors. Patch by pablo Galindo
4 changes: 4 additions & 0 deletions Parser/pegen_errors.c
Expand Up @@ -212,6 +212,10 @@ _PyPegen_tokenize_full_source_to_check_for_errors(Parser *p) {
void *
_PyPegen_raise_error(Parser *p, PyObject *errtype, 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);
Expand Down

0 comments on commit 4d69501

Please sign in to comment.