[issue30951] Documentation error in inspect module
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
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: https://stackoverflow.com/q/45147260/1953800 ---------- 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 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30951> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Changes by Alex <jalex.vig@gmail.com>: ---------- pull_requests: +2802 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30951> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Changes by Alex <jalex.vig@gmail.com>: ---------- pull_requests: +2803 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30951> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Marco Buttu added the comment: Or maybe: "tuple of names of global variables used in the bytecode" ---------- nosy: +marco.buttu _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30951> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Change by Utkarsh Gupta <guptautkarsh2102@gmail.com>: ---------- keywords: +patch pull_requests: +9921 stage: -> patch review _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue30951> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Change by Utkarsh Gupta <guptautkarsh2102@gmail.com>: ---------- nosy: +utkarsh2102 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue30951> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Serhiy Storchaka <storchaka+cpython@gmail.com> 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 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue30951> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Utkarsh Gupta <guptautkarsh2102@gmail.com> added the comment: Serhiy: What change d'you possibly suggest then? ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue30951> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Change by Cheryl Sabella <cheryl.sabella@gmail.com>: ---------- 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 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue30951> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Change by laike9m <laike9m@gmail.com>: ---------- nosy: +laike9m _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue30951> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Xavier Morel <xavier.morel@masklinn.net> 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 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue30951> _______________________________________
participants (8)
-
Alex
-
Alex Vig
-
Cheryl Sabella
-
laike9m
-
Marco Buttu
-
Serhiy Storchaka
-
Utkarsh Gupta
-
Xavier Morel