Skip to content

gh-123142: Fix too wide source locations in tracebacks of exceptions from broken iterables in comprehensions - #123173

Merged
iritkatriel merged 3 commits into
python:mainfrom
iritkatriel:gh-123142
Aug 21, 2024
Merged

gh-123142: Fix too wide source locations in tracebacks of exceptions from broken iterables in comprehensions#123173
iritkatriel merged 3 commits into
python:mainfrom
iritkatriel:gh-123142

Conversation

@iritkatriel

@iritkatrieliritkatriel commented Aug 20, 2024

Copy link
Copy Markdown
Member

@iritkatrieliritkatriel added type-bug An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes labels Aug 20, 2024

@markshannonmarkshannon left a comment

Copy link
Copy Markdown
Member

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

Comment threadLib/test/test_dictcomps.py Outdated
Comment threadLib/test/test_dictcomps.py Outdated
@bedevere-app

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

…tions from broken iterables in comprehensions
@iritkatriel

Copy link
Copy Markdown
MemberAuthor

I have made the requested changes; please review again.

@bedevere-app

Copy link
Copy Markdown

Thanks for making the requested changes!

@markshannon: please review the changes made to this pull request.

@markshannonmarkshannon left a comment

Copy link
Copy Markdown
Member

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.

@iritkatriel
iritkatriel merged commit ec89620 into python:mainAug 21, 2024
@miss-islington-app

Copy link
Copy Markdown

Thanks @iritkatriel for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @iritkatriel, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker ec89620e5e147ba028a46dd695ef073a72000b84 3.13

@miss-islington-app

Copy link
Copy Markdown

Sorry, @iritkatriel, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker ec89620e5e147ba028a46dd695ef073a72000b84 3.12

iritkatriel added a commit to iritkatriel/cpython that referenced this pull request Aug 21, 2024
…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>
@bedevere-app

Copy link
Copy Markdown

GH-123209 is a backport of this pull request to the 3.13 branch.

@bedevere-appbedevere-appBot removed the needs backport to 3.13 bugs and security fixes label Aug 21, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this pull request Aug 21, 2024
…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>
@bedevere-app

Copy link
Copy Markdown

GH-123210 is a backport of this pull request to the 3.12 branch.

@bedevere-appbedevere-appBot removed the needs backport to 3.12 only security fixes label Aug 21, 2024
blhsing pushed a commit to blhsing/cpython that referenced this pull request Aug 22, 2024
iritkatriel added a commit that referenced this pull request Aug 22, 2024
…ptions from broken iterables in comprehensions (GH-123173). (#123209)
(cherry picked from commit ec89620)
iritkatriel added a commit that referenced this pull request Aug 22, 2024
…ptions from broken iterables in comprehensions (GH-123173). (#123210)
(cherry picked from commit ec89620)
@15r10nk

Copy link
Copy Markdown
Contributor

@iritkatriel might it be that this fix changed the source range for exceptions in __init__ and __next__ but not for exceptions in __iter__.

classFoo:
def__iter__(self):
assertFalsea= [xforxinFoo()]

output (Python 3.13.0rc1+):

Traceback (mostrecentcalllast):
File"/home/frank/projects/cpython/codi.py", line5, in<module>a= [xforxinFoo()]
^^^^^^^^^^^^^^^^^^File"/home/frank/projects/cpython/codi.py", line3, in__iter__assertFalse^^^^^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.

@iritkatriel

Copy link
Copy Markdown
MemberAuthor

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.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@iritkatriel@15r10nk@markshannon