-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-45408: Don't override previous tokenizer errors in the second parser pass #28812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is basically where the error was: we were overriding existing tokenizer errors that are different from E_ERROR
. In this case we had E_LINECONT
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick fix Pablo!
Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10. |
Sorry, @pablogsal, I could not cleanly backport this to |
…ond parser pass (pythonGH-28812). (cherry picked from commit 0219017) Co-authored-by: Pablo Galindo Salgado <[email protected]>
GH-28813 is a backport of this pull request to the 3.10 branch. |
…ond parser pass (GH-28812). (GH-28813) (cherry picked from commit 0219017) Co-authored-by: Pablo Galindo Salgado <[email protected]>
https://bugs.python.org/issue45408