diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2022-01-04 10:41:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-04 10:41:22 (GMT) |
commit | 70f415fb8b632247e28d87998642317ca7a652ae (patch) | |
tree | 5e22e01157df0af81065d577f6609c948646ad93 /Parser/pegen_errors.c | |
parent | a94461d7189d7f1147ab304a332c8684263dc17e (diff) | |
download | cpython-70f415fb8b632247e28d87998642317ca7a652ae.zip cpython-70f415fb8b632247e28d87998642317ca7a652ae.tar.gz cpython-70f415fb8b632247e28d87998642317ca7a652ae.tar.bz2 |
bpo-46240: Correct the error for unclosed parentheses when the tokenizer is not finished (GH-30378)
Diffstat (limited to 'Parser/pegen_errors.c')
-rw-r--r-- | Parser/pegen_errors.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Parser/pegen_errors.c b/Parser/pegen_errors.c index 93057d1..f07d9d8 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. |