bpo-46240: Correct the error for unclosed parentheses when the tokenizer is not finished (GH-30378)

This commit is contained in:
Pablo Galindo Salgado 2022-01-04 10:41:22 +00:00 committed by GitHub
parent a94461d718
commit 70f415fb8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 2 deletions

View file

@ -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.