gh-123142: Fix too wide source locations in tracebacks of exceptions from broken iterables in comprehensions#123173
Conversation
markshannon
left a comment
There was a problem hiding this comment.
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. |
markshannon
left a comment
There was a problem hiding this comment.
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 <1055913+iritkatriel@users.noreply.github.com>
|
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 <1055913+iritkatriel@users.noreply.github.com>
|
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
^^^^^
AssertionErrorThis 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.