New submission from Alex Vig:
The documentation for co_names in the inspect module is:
"tuple of names of local variables"
Local variable names are however in co_varnames while co_names contains global variable names. This description should read:
"tuple of names of global variables"
Relevant StackOverflow post here:
---------- assignee: docs@python components: Documentation messages: 298545 nosy: Alex Vig, docs@python priority: normal severity: normal status: open title: Documentation error in inspect module versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7
Marco Buttu added the comment:
Or maybe: "tuple of names of global variables used in the bytecode"
---------- nosy: +marco.buttu
Change by Utkarsh Gupta email@example.com:
---------- keywords: +patch pull_requests: +9921 stage: -> patch review
Serhiy Storchaka firstname.lastname@example.org added the comment:
co_names contains not only names of global variables. It contains also local names in the class scope, attribute names, names of imported modules, etc.
---------- nosy: +serhiy.storchaka
Utkarsh Gupta email@example.com added the comment:
Serhiy: What change d'you possibly suggest then?
Change by Cheryl Sabella firstname.lastname@example.org:
---------- versions: +Python 3.8, Python 3.9 -Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7
Xavier Morel email@example.com added the comment:
Maybe something along the lines of "names other than arguments and function locals", or "names of the symbols used in the code object, other than arguments and function locals"? This is still slightly confusing because in the case of an import the name is present in both mappings, but less so than the outright lie of the current version.
Serhiy, is there a way to access the class's code object from Python? Also does that mean varnames is not used by class code objects despite it stating unambiguously that it stores locals?
---------- nosy: +xmorel