-
-
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
Highlight invalid ranges in SyntaxErrors #88080
Comments
To improve the user experience understanding what part of the error messages associated to SyntaxErrors are wrong, we can highlight the whole error range and not only place the caret at the first character. In this way: >>> foo(x, z for z in range(10), t, w)
File "<stdin>", line 1
foo(x, z for z in range(10), t, w)
^
SyntaxError: Generator expression must be parenthesized becomes >>> foo(x, z for z in range(10), t, w)
File "<stdin>", line 1
foo(x, z for z in range(10), t, w)
^^^^^^^^^^^^^^^^^^^^
SyntaxError: Generator expression must be parenthesized |
What a great, useful change! |
Great!!! I also tried
>>> try: compile("a xyzjdkjfk", '', 'single')
except SyntaxError as e:
print(e, e.msg, e.lineno, e.offset, e.end_lineno, e.end_offset) invalid syntax. Perhaps you forgot a comma? (, line 1) invalid syntax. Perhaps you forgot a comma? 1 1 1 12 The language change that enables the display change is the addition of end_lineno and end_offset attributes. I will look into using these in IDLE. I will submit a PR to augment the What's New entry, so others can also improve their error marking. |
This is complete now. Thanks! ✨ 🍰 ✨ |
New changeset 0eb57c3 by Pablo Galindo (Łukasz Langa) in branch '3.10': New changeset 3397e31 by Pablo Galindo (Miss Islington (bot)) in branch '3.10': |
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: