mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
bpo-46240: Correct the error for unclosed parentheses when the tokenizer is not finished (GH-30378)
This commit is contained in:
parent
a94461d718
commit
70f415fb8b
4 changed files with 9 additions and 2 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue