summaryrefslogtreecommitdiff
path: root/Parser/pegen_errors.c
diff options
context:
space:
mode:
Diffstat (limited to 'Parser/pegen_errors.c')
-rw-r--r--Parser/pegen_errors.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Parser/pegen_errors.c b/Parser/pegen_errors.c
index 93057d151d..f07d9d8a34 100644
--- a/Parser/pegen_errors.c
+++ b/Parser/pegen_errors.c
@@ -388,7 +388,8 @@ _Pypegen_set_syntax_error(Parser* p, Token* last_token) {
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_DONE && PyErr_ExceptionMatches(PyExc_SyntaxError)) {
+ int is_tok_ok = (p->tok->done == E_DONE || p->tok->done == E_OK);
+ if (is_tok_ok && PyErr_ExceptionMatches(PyExc_SyntaxError)) {
_PyPegen_tokenize_full_source_to_check_for_errors(p);
}
// Propagate the existing syntax error.