Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-107901: Fix missing line number on BACKWARD_JUMP at the end of a for loop #108242

Merged
merged 2 commits into from
Aug 21, 2023

Conversation

iritkatriel
Copy link
Member

@iritkatriel iritkatriel commented Aug 21, 2023

@iritkatriel iritkatriel requested a review from sweeneyde August 21, 2023 20:53
@iritkatriel iritkatriel added type-bug An unexpected behavior, bug, or error 3.11 only security fixes 3.12 bugs and security fixes 3.13 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Aug 21, 2023
Copy link
Member

@sweeneyde sweeneyde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I'm not sure how to fix the other lineless instructions you mention, but I think this is a nice simple solution for this case.

@iritkatriel iritkatriel changed the title gh-107901: Fix missing line number on :opcode:BACKWARD_JUMP at the end of a for loop gh-107901: Fix missing line number on BACKWARD_JUMP at the end of a for loop Aug 21, 2023
@iritkatriel iritkatriel merged commit a1cc74c into python:main Aug 21, 2023
@iritkatriel iritkatriel added needs backport to 3.11 only security fixes needs backport to 3.12 bug and security fixes labels Aug 22, 2023
@miss-islington
Copy link
Contributor

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

@miss-islington
Copy link
Contributor

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

@miss-islington
Copy link
Contributor

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 22, 2023
…of a for loop (pythonGH-108242)

(cherry picked from commit a1cc74c)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
@bedevere-bot
Copy link

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

@bedevere-bot bedevere-bot removed the needs backport to 3.12 bug and security fixes label Aug 22, 2023
@iritkatriel iritkatriel removed 3.11 only security fixes 3.12 bugs and security fixes 3.13 bugs and security fixes labels Aug 22, 2023
@@ -531,7 +531,7 @@ normalize_jumps_in_block(cfg_builder *g, basicblock *b) {
if (backwards_jump == NULL) {
return ERROR;
}
basicblock_addop(backwards_jump, JUMP, target->b_label.id, NO_LOCATION);
basicblock_addop(backwards_jump, JUMP, target->b_label.id, last->i_loc);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the last physical location, not the last location executed. Won't it give the wrong line for the following?

ALWAYS_TRUE= True

def foo():
    while 1:
        if ALWAYS_TRUE:
            pass # last line executed
        else:
            pass # last physical line

Copy link
Member Author

@iritkatriel iritkatriel Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, last is the conditional backwards jump that this jump is replacing (and which is replaced by a forward jump).

Yhg1s pushed a commit that referenced this pull request Aug 22, 2023
… of a for loop (GH-108242) (#108275)

gh-107901: Fix missing line number on BACKWARD_JUMP at the end of a for loop (GH-108242)
(cherry picked from commit a1cc74c)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) needs backport to 3.11 only security fixes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants