-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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-30951: Correct co_names documentation in inspect module #2743
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
@jalexvig, thanks for your PR! By analyzing the history of the files in this pull request, we identified @Yhg1s, @1st1 and @zestyping to be potential reviewers. |
Lib/inspect.py
Outdated
@@ -268,7 +268,7 @@ def iscode(object): | |||
co_kwonlyargcount number of keyword only arguments (not including ** arg) | |||
co_lnotab encoded mapping of line numbers to bytecode indices | |||
co_name name with which this code object was defined | |||
co_names tuple of names of local variables | |||
co_names tuple of names of global variables |
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.
What about tuple of names of global variables used in the bytecode?
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 description is currently under the code
type... The other descriptions don't make explicit reference to bytecode (except for co_consts
) since it is implied by the code
type. Would be pretty repetitive to add reference to the bytecode in every description. Thoughts?
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.
The difference here is that "tuple of names of global variables" would be potentially misleading, since only those global variables used by the bytecode are included. (IIUC) This item is parallel to co_consts in that sense.
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 @bitdancer, you pointed out perfectly my concern :-)
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.
Ah gotcha - updating.
fc5a4bc
to
17cb727
Compare
|
@jalexvig, please take a look at incorporating the note from @serhiy-storchaka in your change. Thanks! |
Added the |
So I'm guessing, |
@jalexvig ping |
Kindly ping |
17cb727
to
960d871
Compare
960d871
to
a223eca
Compare
I haven't looked at this in a while, but updated with suggestion from Xavier Morel. |
Closing and re-opening to re-trigger CI. |
GH-28543 is a backport of this pull request to the 3.10 branch. |
GH-28544 is a backport of this pull request to the 3.9 branch. |
(cherry picked from commit 3f8b23f) Co-authored-by: Alex Vig <[email protected]>
(cherry picked from commit 3f8b23f) Co-authored-by: Alex Vig <[email protected]>
…-28544) (cherry picked from commit 3f8b23f) Co-authored-by: Alex Vig <[email protected]>
…-28543) (cherry picked from commit 3f8b23f) Co-authored-by: Alex Vig <[email protected]>
…-28543) (cherry picked from commit 3f8b23f) Co-authored-by: Alex Vig <[email protected]>
Previously
co_names
was described as containing names of local variables.co_names
however contains names of global variables (co_varnames
contains local variable names). Documentation was updated to reflect this.Relevant stackoverflow post:
https://stackoverflow.com/questions/45147260/what-is-co-names
https://bugs.python.org/issue30951