diff options
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/pegen.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c index 7e2d37c..a989635 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -1342,13 +1342,16 @@ _PyPegen_run_parser(Parser *p) { void *res = _PyPegen_parse(p); if (res == NULL) { + if (PyErr_Occurred() && !PyErr_ExceptionMatches(PyExc_SyntaxError)) { + return NULL; + } Token *last_token = p->tokens[p->fill - 1]; reset_parser_state(p); _PyPegen_parse(p); if (PyErr_Occurred()) { // Prioritize tokenizer errors to custom syntax errors raised // on the second phase only if the errors come from the parser. - if (p->tok->done != E_ERROR && PyErr_ExceptionMatches(PyExc_SyntaxError)) { + if (p->tok->done == E_DONE && PyErr_ExceptionMatches(PyExc_SyntaxError)) { _PyPegen_check_tokenizer_errors(p); } return NULL; |