-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
[3.12] gh-111609: end_offset
is ignored in subclasses of SyntaxError
#127554
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
Conversation
@pablogsal, do you remember why this check was added in #25525? This works fine: >>> class CustomSyntaxError(SyntaxError):
... def __init__(self, msg, filename, lineno, offset, text, end_lineno, end_offset):
... self.msg = msg
... self.filename = filename
... self.lineno = lineno
... self.offset = offset
... self.text = text
... # self.end_lineno = end_lineno
... # self.end_offset = end_offset
...
>>> raise CustomSyntaxError("Error message", None, 1, 5, 'a = sin(3)', 1, 9)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1
a = sin(3)
^
CustomSyntaxError: Error message |
What check are you referring to? The subclass check? IIRC is because some people were using some subclasses of syntax errors that were yielding weird results when displayed but I searched for the conversation and could not find anything :S |
@@ -2195,6 +2195,22 @@ def test_range_of_offsets(self): | |||
self.assertIn(expected, err.getvalue()) | |||
the_exception = exc | |||
|
|||
def test_subclass(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add this test to main if is not there already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a PR: #127830
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for the catch @nineteendo!
Example:
main:
PR:
end_offset
is ignored in subclasses of SyntaxError (3.12-only) #111609