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
Fix attributes of syntax errors raized in the tokenizer #83400
Comments
SyntaxError can be raised at different stages of compiling. In some places the source text is not available and should be read from the file using the file name. Which does not work in case of compiling a string or reading from stdin. >>> 0z
File "<stdin>", line 1
0z
^
SyntaxError: invalid syntax
>>> 0xz
File "<stdin>", line 1
SyntaxError: invalid hexadecimal literal In the second example above the source line and the caret are absent in REPL. The proposed PR fixes two errors in raising a SyntaxError in the tokenizer.
It only fixes errors in the tokenizer. There are similar bugs in other parts of the compiler. This issue is based on the article https://aroberge.blogspot.com/2019/12/a-tiny-python-exception-oddity.html . |
On entry of '0xz', IDLE from 3.6 to date highlights the '0x' part of the original entry. I presume it can do this because it ignores the text attribute, and because bytes == chars for at least '0x'. The 'proposed PR' is not listed here. Is it not yet submitted, or is the issue number wrong? |
Sorry, wrong issue number. |
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: