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
pegen parser: Multiline eval with assignment to function call: assertion failed #86993
Comments
Tested in 3.9.0 and master (127dde5): $ cat test.py
eval(
"""[file for str(file) in []
]
"""
)
$ ./python test.py
python: Parser/pegen.c:149: byte_offset_to_character_offset: Assertion `col_offset >= 0 && (unsigned long)col_offset <= strlen(str)' failed.
Fatal Python error: Aborted Current thread 0x00007f6454cfe280 (most recent call first): (Adding Guido and Pablo to nosy as, IIRC, you're interested in parser things :)) |
Reproducer as a single line: compile("[file for str(file) in []\n]", "string", "exec") |
According to git bisect it come from 01ece63, thanks Victor for adding Lysandros, you had a good feeling :) |
Thanks for letting us know, Julien! I've identified the bug and where it comes from and I'll probably work on it tomorrow. |
This is now fixed. |
On Windows, Victor's one liner failed on repository debug builds with Windows' process error popup. I have seen this mysterious failure at least once when testing IDLE Shell running on the repository build. After the patch, my debug build gives the correct message, Installed Python 3.10.0a4, Jan 4, gives the correct message but confusingly points at the final ']' on a line by itself. The latter should be fixed in the next release. |
In order to test code.InteractiveCompiler (used by IDLE) and codeop._maybe_compile (which IC calls), which calls compile() 3 times with mode 'single', I entered the example as 2 or 3 lines in Shell.
>>> [file for str(file) in [] # Error highlight on 's'.
]
SyntaxError: cannot assign to function call Breaking the expression elsewhere, including before 'str', gives the same message and highlighted 's'. I did not test before recompiling but it is certainly correct now. |
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: