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-107901: make compiler inline basic blocks with no line number and no fallthrough by iritkatriel · Pull Request #114750 · python/cpython

Conversation

@iritkatriel

@iritkatriel iritkatriel commented Jan 30, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

This pattern shows up in code like this:

def f():         
    for e in seq:
        try:
            X = 3
        except OSError:
            try:
                if C3:
                    X = 4
            except OSError:
                pass
    return 42

We have a block with no line number, and two predecessors, which contains a jump to another block that has no line number. The two-predecessor block is not an exit block so it is not duplicated. As a result, the end block remains with no line number, even if it needs one. This change inlines the first block to each of its predecessors, so that the jump can get a line number.

  • Issue: Traceback says line -1 when KeyboardInterrupt during minimal for-if-loop  #107901

Sorry, something went wrong.

Uh oh!

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

All reactions
@iritkatriel
pythongh-107901: make compiler inline basic blocks with no line numbe…
eb06eb2
…r and no fallthrough
@iritkatriel
iritkatriel requested a review from markshannon as a code owner January 30, 2024 12:05
@bedevere-app bedevere-app Bot mentioned this pull request Jan 30, 2024
Traceback says line -1 when KeyboardInterrupt during minimal for-if-loop #107901
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Jan 30, 2024
@iritkatriel
Merge branch 'main' into inline-blocks-without-lineno
dcd2f95
@iritkatriel iritkatriel added the skip news label Jan 30, 2024
@iritkatriel
Merge branch 'main' into inline-blocks-without-lineno
da4a47e
@markshannon

markshannon commented Feb 1, 2024

Copy link
Copy Markdown
Member

Two questions.

  • Does this fix handle triply nested try-excepts?
  • Is it feasible to add a test for this?
All reactions

Sorry, something went wrong.

Uh oh!

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

@iritkatriel

iritkatriel commented Feb 1, 2024

Copy link
Copy Markdown
Member Author
  • Does this fix handle triply nested try-excepts?

It does. The issue is not the nesting, but the multiple paths leading to the end of the except block. It needs to be nested in another except because otherwise the blocks get reordered and this impacts the situation. But with nesting all the blocks are cold, so they remain in this order. More nesting doesn't make a difference.

  • Is it feasible to add a test for this?

I'll try to add a unit test.

This PR makes the build pass with the assertion that all eval break checks have line numbers (there are 3 more test failures then, but at least we get through the build).

All reactions

Sorry, something went wrong.

Uh oh!

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

@iritkatriel
add tests
7bef890
markshannon
markshannon approved these changes Feb 2, 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

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 core review labels Feb 2, 2024
@iritkatriel
iritkatriel merged commit 2091fb2 into python:main Feb 2, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Feb 2, 2024
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
@iritkatriel @aisk
pythongh-107901: make compiler inline basic blocks with no line numbe…
f9f3ae4
…r and no fallthrough (python#114750)
fsc-eriker pushed a commit to fsc-eriker/cpython that referenced this pull request Feb 14, 2024
@iritkatriel @fsc-eriker
pythongh-107901: make compiler inline basic blocks with no line numbe…
1b563ed
…r and no fallthrough (python#114750)
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

No one assigned

Labels

skip news

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.

2 participants

@iritkatriel @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 01402520 — 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.