-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Conversation
iritkatriel
commented
Aug 21, 2023
•
edited by bedevere-bot
Loading
edited by bedevere-bot
- Issue: Traceback says line -1 when KeyboardInterrupt during minimal for-if-loop #107901
Misc/NEWS.d/next/Core and Builtins/2023-08-21-21-13-30.gh-issue-107901.hszvdk.rst
Outdated
Show resolved
Hide resolved
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.
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.
BACKWARD_JUMP
at the end of a for loop
Thanks @iritkatriel for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11. |
Thanks @iritkatriel for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Sorry, @iritkatriel, I could not cleanly backport this to |
…of a for loop (pythonGH-108242) (cherry picked from commit a1cc74c) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
GH-108275 is a backport of this pull request to the 3.12 branch. |
@@ -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); |
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.
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
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.
no, last
is the conditional backwards jump that this jump is replacing (and which is replaced by a forward jump).