Repository navigation
Misleading __version__ attribute of modules in standard library #76007
Copy link
Copy link
Closed
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
| BPO | 31826 |
|---|---|
| Nosy | @warsaw, @rhettinger, @ncoghlan, @pitrou, @merwok, @encukou, @serhiy-storchaka, @abukaj, @cryvate |
| PRs |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = None
closed_at = None
created_at = <Date 2017-10-20.13:21:04.010>
labels = ['3.7', 'type-bug', 'library']
title = 'Misleading __version__ attribute of modules in standard library'
updated_at = <Date 2020-02-04.10:54:36.743>
user = 'https://github.com/abukaj'bugs.python.org fields:
activity = <Date 2020-02-04.10:54:36.743>
actor = 'cryvate'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2017-10-20.13:21:04.010>
creator = 'abukaj'
dependencies = []
files = []
hgrepos = []
issue_num = 31826
keywords = ['patch']
message_count = 7.0
messages = ['304654', '304763', '304765', '304779', '304780', '304823', '361340']
nosy_count = 9.0
nosy_names = ['barry', 'rhettinger', 'ncoghlan', 'pitrou', 'eric.araujo', 'petr.viktorin', 'serhiy.storchaka', 'abukaj', 'cryvate']
pr_nums = ['17977']
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue31826'
versions = ['Python 3.7']Linked PRs
- gh-76007: Deprecate
__version__attribute #138675 - gh-76007:
pydoc: CatchDeprecationWarningfor stdlib module__version__attributes #139997 - gh-76007: Deprecate
zlib.__version__attribute #140130 - gh-76007: Deprecate
__version__attribute inimaplib#140299 - gh-76007: Deprecate
__version__attribute indecimal#140302 - gh-76007: remove curses.__version__ doc #141052
- [3.14] gh-76007: remove curses.__version__ doc (GH-141052) #141076
- [3.13] gh-76007: remove curses.__version__ doc (GH-141052) #141077
- gh-76007: Deprecate
__version__attribute inhttp.server#142658 - gh-76007: Deprecate
__version__attribute inwsgiref.simple_server#142675 - gh-76007: Deprecate
__version__attribute inctypes#142679 - gh-76007: Deprecate
VERSIONinxml.etree.ElementTree&versioninxml.sax.expatreader&xml.sax.handler#142898 - gh-76007: Deprecate
tarfile.version#145326
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
abukaj commentedon Oct 20, 2017
Several modules of the standard library (at least
reandcsv) have__version__strings.The string is the same for Python 2.7-3.6:
>>> import re, csv; print(re.__version__, csv.__version__) 2.2.1 1.0while documentation indicates changes in the modules.
Semantic versioning (recommended by PEP-440) suggests that at least minor version should change in such case.
I suspect it to be a "code fossil" which may be removed according to PEP-396.
rhettinger commentedon Oct 22, 2017
I would support just removing the version attributes for csv and re.
pitrou commentedon Oct 22, 2017
+1 for removing __version__ on all stdlib modules which are not externally maintained.
ncoghlan commentedon Oct 23, 2017
+1 from me for dropping these, and noting which modules were affected in the Porting section of the 3.7 What's New (I'd be surprised if anyone was depending on them existing, but it doesn't hurt to mention it, and may help if someone is trying to figure out what changed)
rhettinger commentedon Oct 23, 2017
Please do leave version in the decimal module where it has a precise meaning, tracking a particular version of the spec that was implemented and tested.
merwok commentedon Oct 23, 2017
The version in distutils is derived from sys.version and should be left as is too. Thanks!
encukou commentedon Feb 4, 2020
PR for removing __version__ from mock: #17977
furkanonder commentedon May 13, 2023
@encukou The issue seems to have been resolved. Can we close the issue?
encukou commentedon May 15, 2023
There are still a lot of modules with
__version__IMO, to resolve it properly:
test___all__, to avoid regressions__version__has a meaning, that fact should be documented -- either we want users to use it, or there's no point exposing itNote that nowadays, the proper way to remove an attribute is with a deprecation period using module
__getattr__.smontanaro commentedon Jan 17, 2024
I just migrated
__version__from_csv.ctocsv.py. I was unaware of this discussion. I'm happy to remove it altogether. Can someone explain to me how this trend came about? I was a bit surprised to see it at all w.r.t. the csv module.erlend-aasland commentedon Jan 17, 2024
Related issue:
35 remaining items
pythongh-76007: remove curses.__version__ doc (python#141052)
gh-76007: Deprecate `__version__` attribute in `http.server` (#142658)
gh-76007: `pydoc`: Catch `DeprecationWarning` for stdlib module `__ve…
hugovk commentedon Dec 14, 2025
I think we're done with
__version__once #142675 and #142679 are merged, or are there any more to do?There's also a
VERSIONand a couple ofversions we could deprecate:cpython/Lib/xml/etree/ElementTree.py
Line 93 in 04da416
cpython/Lib/xml/sax/expatreader.py
Line 6 in 04da416
cpython/Lib/xml/sax/handler.py
Line 12 in 04da416
Thoughts?
gh-76007: Deprecate `__version__` attribute in `ctypes` (#142679)
pythongh-76007: `pydoc`: Catch `DeprecationWarning` for stdlib module…
pythongh-76007: Deprecate `__version__` attribute in `ctypes` (python…
gh-76007: Deprecate `__version__` attribute in `wsgiref.simple_server` (
hugovk commentedon Dec 17, 2025
PR #142898 for that, to close this issue.
gh-76007: Deprecate `VERSION` in `xml.etree.ElementTree` & `version` …
pythongh-76007: Deprecate `VERSION` in `xml.etree.ElementTree` & `ver…
gh-76007: Deprecate `tarfile.version` (#145326)
pythongh-76007: Deprecate `tarfile.version` (python#145326)
pythongh-76007: Deprecate `tarfile.version` (python#145326)