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-46422: use dis.Positions in dis.Instruction #30716

Merged
merged 6 commits into from Jan 24, 2022

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Jan 20, 2022

Copy link
Sponsor Member

@isidentical isidentical left a comment

Thanks for the PR @sobolevn!

  • The tests only seem to cover cases where the code object is missing one of the position tables. Let's add a test like test_co_positions which uses the new positions API.
  • Let's also document the new API

Lib/dis.py Outdated
@@ -414,7 +414,7 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
argval = None
argrepr = ''
try:
positions = next(co_positions)
positions = Positions(*next(co_positions))
except StopIteration:
positions = None
Copy link
Sponsor Member

@isidentical isidentical Jan 20, 2022

Choose a reason for hiding this comment

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

Let's simply create an empty Positions() object here.

@bedevere-bot
Copy link

bedevere-bot commented Jan 20, 2022

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@sobolevn
Copy link
Member Author

sobolevn commented Jan 20, 2022

Thanks for the feedback! I've added docs about position field, but I didn't cover Positions namedtuple explicitly. I hope that reference to some "namedtuple" is good enough. But, I can fix it if needed 🙂

I have made the requested changes; please review again.

@bedevere-bot
Copy link

bedevere-bot commented Jan 20, 2022

Thanks for making the requested changes!

@isidentical: please review the changes made to this pull request.

@bedevere-bot bedevere-bot requested a review from isidentical Jan 20, 2022
Copy link
Sponsor Member

@isidentical isidentical left a comment

Thanks a lot, I think it looks good as is but let's clear the documentation a bit.

Doc/library/dis.rst Outdated Show resolved Hide resolved
Doc/library/dis.rst Outdated Show resolved Hide resolved
Doc/library/dis.rst Outdated Show resolved Hide resolved
@isidentical
Copy link
Sponsor Member

isidentical commented Jan 24, 2022

Azure is weirdly failing 🤦🏻 Closing/Re-opening to restart.

@isidentical isidentical reopened this Jan 24, 2022
@isidentical isidentical merged commit 58f3d98 into python:main Jan 24, 2022
21 checks passed
@isidentical
Copy link
Sponsor Member

isidentical commented Jan 24, 2022

Thanks very much for noticing (and fixing) this @sobolevn!

@sobolevn
Copy link
Member Author

sobolevn commented Jan 24, 2022

Thanks for the review! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants