GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-123142: Fix too wide source locations in tracebacks of exceptions from broken iterables in comprehensions by iritkatriel · Pull Request #123173 · python/cpython

Conversation

@iritkatriel

@iritkatriel iritkatriel commented Aug 20, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: Source locations too broad for list comprehension iterable expression #123142

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@iritkatriel iritkatriel 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 only security fixes labels Aug 20, 2024
@iritkatriel
iritkatriel requested a review from markshannon as a code owner August 20, 2024 11:32
@bedevere-app bedevere-app Bot mentioned this pull request Aug 20, 2024
Source locations too broad for list comprehension iterable expression #123142
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Aug 20, 2024
markshannon
markshannon requested changes Aug 21, 2024
View reviewed changes

@markshannon markshannon left a comment

Copy link
Copy Markdown
Member

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_dictcomps.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_dictcomps.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting core review label Aug 21, 2024
@bedevere-app

bedevere-app Bot commented Aug 21, 2024

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting changes label Aug 21, 2024
@iritkatriel
pythongh-123142: Fix too wide source locations in tracebacks of excep…
a92a12e
…tions from broken iterables in comprehensions
@iritkatriel
iritkatriel force-pushed the gh-123142 branch from 30ee953 to a92a12e Compare August 21, 2024 15:34
@iritkatriel
dedup tests
3b4c2f8
@iritkatriel

iritkatriel commented Aug 21, 2024

Copy link
Copy Markdown
Member Author

I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting change review and removed awaiting changes labels Aug 21, 2024
@bedevere-app

bedevere-app Bot commented Aug 21, 2024

Copy link
Copy Markdown

Thanks for making the requested changes!

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app
bedevere-app Bot requested a review from markshannon August 21, 2024 15:50
markshannon
markshannon approved these changes Aug 21, 2024
View reviewed changes

@markshannon markshannon left a comment

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting change review labels Aug 21, 2024
@iritkatriel
update locations in test_compile
0e3233c
@iritkatriel
iritkatriel merged commit ec89620 into python:main Aug 21, 2024
@miss-islington-app

miss-islington-app Bot commented Aug 21, 2024

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Aug 21, 2024
@miss-islington-app

miss-islington-app Bot commented Aug 21, 2024

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
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app miss-islington-app Bot assigned iritkatriel Aug 21, 2024
@miss-islington-app

miss-islington-app Bot commented Aug 21, 2024

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
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

iritkatriel added a commit to iritkatriel/cpython that referenced this pull request Aug 21, 2024
@iritkatriel
[3.13] pythongh-123142: Fix too wide source locations in tracebacks o…
d54bd16
…f exceptions from broken iterables in comprehensions (pythonGH-123173).

(cherry picked from commit ec89620)

Co-authored-by: Irit Katriel <[email protected]>
@bedevere-app

bedevere-app Bot commented Aug 21, 2024

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Aug 21, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this pull request Aug 21, 2024
@iritkatriel
[3.12] pythongh-123142: Fix too wide source locations in tracebacks o…
ec46da6
…f exceptions from broken iterables in comprehensions (pythonGH-123173).

(cherry picked from commit ec89620)

Co-authored-by: Irit Katriel <[email protected]>
@bedevere-app

bedevere-app Bot commented Aug 21, 2024

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot 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 @blhsing
pythongh-123142: Fix too wide source locations in tracebacks of excep…
8293796
…tions from broken iterables in comprehensions (python#123173)
iritkatriel added a commit that referenced this pull request Aug 22, 2024
@iritkatriel
[3.13] gh-123142: Fix too wide source locations in tracebacks of exce…
e4b91b7
…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
@iritkatriel
[3.12] gh-123142: Fix too wide source locations in tracebacks of exce…
fbbde4d
…ptions from broken iterables in comprehensions (GH-123173). (#123210)

(cherry picked from commit ec89620)
@15r10nk

15r10nk commented Aug 26, 2024

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__.

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iritkatriel

iritkatriel commented Aug 27, 2024

Copy link
Copy Markdown
Member Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iritkatriel iritkatriel mentioned this pull request Aug 28, 2024
gh-123142: fix too wide source location of GET_ITER/GET_AITER #123420
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@markshannon markshannon markshannon approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@iritkatriel iritkatriel

Labels

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

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@iritkatriel @15r10nk @markshannon
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.