-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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-46724: Fix dis support for overflow args #31285
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
Adds support for negative relative jump args introduced in Python 3.10. Ports corresponding fix from dis python/cpython#31285
Adds support for negative relative jump args introduced in Python 3.10. Ports corresponding fix from dis python/cpython#31285
Misc/NEWS.d/next/Library/2022-02-11-20-41-17.bpo-46724.eU52_N.rst
Outdated
Show resolved
Hide resolved
@JelleZijlstra Thanks for taking a look. Would you be able to approve the actions to run on this PR so I can see if the tests pass in CI? |
Sorry, I don't have that power. |
Lib/dis.py
Outdated
# Rely on C `int` being 32 bits for oparg | ||
_INT_BITS = 32 | ||
# Maximum value for a c int | ||
_INT_MAX = 2 ** (_INT_BITS - 1) |
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 when it overflows, not the maximum value.
Rather than messing around with subtracting one, I'd recommend renaming this to _INT_OVERFLOW
.
The math is sound.
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.
Thanks for catching, fixed!
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.
One quibble about naming, otherwise looks good.
8ad2b32
to
2ababec
Compare
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
I removed the review requests. In the future, it's better to merge main into the branch instead of rebasing. Thanks for updating it, I can take another look at the PR later. |
@JelleZijlstra thank you for removing them.
Will do. |
Thanks @saulshanabrook |
This PR makes dis aware that currently Python's opargs wrap after a certain value. This is used in Python 3.10+ for code which includes negative args to represent negative jumps, like this:
which produces this
dis
output after this PR:Before this PR, the
JUMP_FORWARD
on line 54 had a huge value that did not match the Python interpreters behavior.It is unclear to me whether producing this sort of bytecode is intended (I assume it's not), but at least with this fix the
dis
output more closes matches the current implementation.https://bugs.python.org/issue46724