-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Inconsistency with lineno and col_offset info when parsing elif #83212
Comments
While working on pegen, we came across an inconsistency on how line number and column offset info is stored for (el)if nodes. When parsing a very simple if-elif construct like if a:
pass
elif b:
pass the following parse tree gets generated: Module( There is the inconsistency that the column offset for the if statement is 0, thus the if statement starts with the keyword if, whereas the column offset for elif if 5, which means that the elif keyword is skipped. As Guido suggests over at we-like-parsers/pegen_experiments#107 (comment) we could very easily change Python/ast.c so that the elif statement start with the elif keyword as well. I have a PR ready! |
Hmmm, there is some problem with the CI and the 3.7 branch. Seems like Travis CI is giving some problems again.... I will investigate or maybe ask Brett to make the check not required again (we still have Azure Pipelines, testing the same thing). |
The same thing happens with 3.8..... |
There was a bug in my last PR, hopefully I will get a fix some time later today. The bug is as follows: I only updated the asdl_seq_SET call for an elif without an else, if an else is included then the behavior is like before. After my last PR it looks like this, parsing 2:if a: outputs the following AST: Module( On the other hand parsing 2:if a: outputs Module( |
Thanks, Lysandros for the quick fix! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: