-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-123142: Fix too wide source locations in tracebacks of exceptions from broken iterables in comprehensions #123173
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
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.
The code change looks good.
At least class Iter
and maybe some more of the tests could be shared
When you're done making the requested changes, leave the comment: |
…tions from broken iterables in comprehensions
I have made the requested changes; please review again. |
Thanks for making the requested changes! @markshannon: please review the changes made to this pull request. |
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.
Looks good.
The code in the three with self.subTest(func)
blocks look the same/very similar. I think they could be factored out, but that might just end up obscuring the intent. It's up to you if you want to factor it further.
Thanks @iritkatriel for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
Sorry, @iritkatriel, I could not cleanly backport this to
|
Sorry, @iritkatriel, I could not cleanly backport this to
|
…f exceptions from broken iterables in comprehensions (pythonGH-123173). (cherry picked from commit ec89620) Co-authored-by: Irit Katriel <[email protected]>
GH-123209 is a backport of this pull request to the 3.13 branch. |
…f exceptions from broken iterables in comprehensions (pythonGH-123173). (cherry picked from commit ec89620) Co-authored-by: Irit Katriel <[email protected]>
GH-123210 is a backport of this pull request to the 3.12 branch. |
…tions from broken iterables in comprehensions (python#123173)
@iritkatriel might it be that this fix changed the source range for exceptions in class Foo:
def __iter__(self):
assert False
a = [x for x in Foo()] output (Python 3.13.0rc1+): Traceback (most recent call last):
File "/home/frank/projects/cpython/codi.py", line 5, in <module>
a = [x for x in Foo()]
^^^^^^^^^^^^^^^^^^
File "/home/frank/projects/cpython/codi.py", line 3, in __iter__
assert False
^^^^^
AssertionError This is the example from the issue and I'm a little confused as to whether it was just forgotten or if I'm missing something here. |
So it seems. The test doesn't check for this too. Thanks for reporting, I'll fix. |
Uh oh!
There was an error while loading. Please reload this page.