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

bpo-42810: Mark jumps at end of if and try statements as artificial. #24091

Merged
merged 3 commits into from
Jan 4, 2021

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Jan 4, 2021

This PR marks jumps with no corresponding source token as artificial.
These jumps occur at the end of the body of an if statement, in and/or expression and in try statements.

Also fixes https://bugs.python.org/issue42803

Skipping NEWS as this PR is cleaning up a very recent regression.

https://bugs.python.org/issue42810

@@ -1528,6 +1535,11 @@ compiler_addop_j(struct compiler *c, int opcode, basicblock *b)
return 0; \
}

#define ADDOP_JUMP_NOLINE(C, OP, O) { \
Copy link
Member

@pablogsal pablogsal Jan 4, 2021

Choose a reason for hiding this comment

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

Small suggestion (I haven't checked all the PR in detail): we could use something like ADDOP_ARTIFICIAL_JUMP instead of ADDOP_JUMP_NOLINE so is clear the kind of jump more than how it will behave

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I prefer NOLINE to ARTIFICIAL. NOLINE explains what it does, ARTIFICIAL explains why.
I'd prefer the code to say what it does, and leave the "why" to comments.
I'll add a comment to explain why the opcode should have no line number.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense

@markshannon markshannon merged commit 127dde5 into python:master Jan 4, 2021
@markshannon markshannon deleted the mark-jumps-as-artificial branch January 4, 2021 18:12
@nedbat
Copy link
Member

nedbat commented Jan 5, 2021

Thanks for fixing it! The release dice were not in our favor: it missed being in 3.10.0a4 by one commit!

adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
…ythonGH-24091)

* Mark jumps at end of if and try statements as artificial.

* Update importlib

* Add comment explaining the purpose of ADDOP_JUMP_NOLINE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants