This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Documentation error in inspect module
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, jalexvig, laike9m, lukasz.langa, marco.buttu, miss-islington, pablogsal, serhiy.storchaka, utkarsh2102, xmorel
Priority: normal Keywords: patch

Created on 2017-07-17 17:29 by jalexvig, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 2742 closed jalexvig, 2017-07-17 19:01
PR 2743 merged jalexvig, 2017-07-17 19:38
PR 10668 closed utkarsh2102, 2018-11-22 22:12
PR 28543 merged miss-islington, 2021-09-24 10:05
PR 28544 merged miss-islington, 2021-09-24 10:05
Messages (10)
msg298545 - (view) Author: Alex (jalexvig) * Date: 2017-07-17 17:29
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
msg298644 - (view) Author: Marco Buttu (marco.buttu) * Date: 2017-07-19 08:49
Or maybe: "tuple of names of global variables used in the bytecode"
msg330300 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-11-23 08:58
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.
msg334563 - (view) Author: Utkarsh Gupta (utkarsh2102) * Date: 2019-01-30 14:54
Serhiy: What change d'you possibly suggest then?
msg372358 - (view) Author: Xavier Morel (xmorel) * Date: 2020-06-25 12:09
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?
msg402547 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-24 10:05
New changeset 3f8b23f8ddab75d9b77a3997d54e663187e12cc8 by Alex Vig in branch 'main':
bpo-30951: Correct co_names docstring in inspect module (GH-2743)
https://github.com/python/cpython/commit/3f8b23f8ddab75d9b77a3997d54e663187e12cc8
msg402548 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-24 10:38
New changeset 91a5ba1bcb24c87a82c1417b1e5df57c89cbd3e0 by Miss Islington (bot) in branch '3.9':
bpo-30951: Correct co_names docstring in inspect module (GH-2743) (GH-28544)
https://github.com/python/cpython/commit/91a5ba1bcb24c87a82c1417b1e5df57c89cbd3e0
msg402549 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-24 10:38
New changeset 402d5f3d77684c91ad02a2ab5223673bec5f1602 by Miss Islington (bot) in branch '3.10':
bpo-30951: Correct co_names docstring in inspect module (GH-2743) (GH-28543)
https://github.com/python/cpython/commit/402d5f3d77684c91ad02a2ab5223673bec5f1602
msg402550 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-24 10:39
Thanks, Alex! ✨ 🍰 ✨
msg403159 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-10-04 19:18
New changeset 7d652c1b7a56524fec42f65d9be28c17888075ab by Pablo Galindo (Miss Islington (bot)) in branch '3.10':
bpo-30951: Correct co_names docstring in inspect module (GH-2743) (GH-28543)
https://github.com/python/cpython/commit/7d652c1b7a56524fec42f65d9be28c17888075ab
History
Date User Action Args
2022-04-11 14:58:49adminsetgithub: 75134
2021-10-04 19:18:42pablogsalsetnosy: + pablogsal
messages: + msg403159
2021-09-24 10:39:41lukasz.langasetstatus: open -> closed
versions: + Python 3.10, Python 3.11, - Python 3.8
type: behavior
messages: + msg402550

resolution: fixed
stage: patch review -> resolved
2021-09-24 10:38:59lukasz.langasetmessages: + msg402549
2021-09-24 10:38:54lukasz.langasetmessages: + msg402548
2021-09-24 10:05:47miss-islingtonsetpull_requests: + pull_request26928
2021-09-24 10:05:43miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request26927
2021-09-24 10:05:40lukasz.langasetnosy: + lukasz.langa
messages: + msg402547
2020-06-25 12:09:04xmorelsetnosy: + xmorel
messages: + msg372358
2020-03-23 05:17:57laike9msetnosy: + laike9m
2020-01-20 18:07:15cheryl.sabellasetversions: + Python 3.8, Python 3.9, - Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7
2019-01-30 14:54:29utkarsh2102setmessages: + msg334563
2018-11-23 08:58:28serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg330300
2018-11-22 22:41:40utkarsh2102setnosy: + utkarsh2102
2018-11-22 22:12:56utkarsh2102setkeywords: + patch
stage: patch review
pull_requests: + pull_request9921
2017-07-19 08:49:57marco.buttusetnosy: + marco.buttu
messages: + msg298644
2017-07-17 19:38:27jalexvigsetpull_requests: + pull_request2803
2017-07-17 19:01:45jalexvigsetpull_requests: + pull_request2802
2017-07-17 17:29:35jalexvigcreate