-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Make traceback module's formatting of SyntaxError more similar to system formatting #84792
Comments
The traceback module formats several edge cases of SyntaxError different than CPython's default formatting.
I propose to make the traceback module behave the same way as the system module in all cases. I also propose to make both suppress the caret if the offset is <= 0. Finally I propose to make the system formatting limit the offset to just past the end of the source text. I propose not to bother changing anything in 3.8 or before. |
Agreed on everything. One thing I don't really understand is if you propose to also strip trailing whitespace. Does "limit the offset to just past the end of the source text" include whitespace or not? For example, the linked PR does not change this behavior: ➜ cpython git:(pr/20072) ./python
Python 3.9.0a6+ (heads/pr/20072:6df7662ca5, May 14 2020, 20:37:50)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> compile('1 + ', '<string>', 'exec')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1
1 +
^
SyntaxError: invalid syntax Should we clip just past the end of |
My current PR does not strip trailing whitespace. It only strips a single trailing newline (since this is usually but not always present, and we don't want to its presence to cause an extra blank line, nor do we want its absence to cause the text line and the caret line to be run together). |
(And, to be clear, I don't *want* to strip trailing spaces.) |
Understood. |
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: