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
Sorry, something went wrong.
|
When you're done making the requested changes, leave the comment: |
Sorry, something went wrong.
…tions from broken iterables in comprehensions
|
I have made the requested changes; please review again. |
Sorry, something went wrong.
|
Thanks for making the requested changes! @markshannon: please review the changes made to this pull request. |
Sorry, something went wrong.
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.
Sorry, something went wrong.
|
Thanks @iritkatriel for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
Sorry, something went wrong.
|
Sorry, @iritkatriel, I could not cleanly backport this to |
Sorry, something went wrong.
|
Sorry, @iritkatriel, I could not cleanly backport this to |
Sorry, something went wrong.
…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>
…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>
…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. |
Sorry, something went wrong.
So it seems. The test doesn't check for this too. Thanks for reporting, I'll fix. |
Sorry, something went wrong.
edited by bedevere-app
Bot
LoadingUh oh!
There was an error while loading. Please reload this page.
Copy link Copy MarkdownSorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.