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=Noneclosed_at=Nonecreated_at=<Date2017-10-20.13:21:04.010>labels= ['3.7', 'type-bug', 'library']
title='Misleading __version__ attribute of modules in standard library'updated_at=<Date2020-02-04.10:54:36.743>user='https://github.com/abukaj'
+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)
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.
I just migrated __version__ from _csv.c to csv.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.
Activity
abukaj commented on Oct 20, 2017
Several modules of the standard library (at least re and csv) 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 commented on Oct 22, 2017
I would support just removing the version attributes for csv and re.
pitrou commented on Oct 22, 2017
+1 for removing __version__ on all stdlib modules which are not externally maintained.
ncoghlan commented on 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 commented on 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 commented on Oct 23, 2017
The version in distutils is derived from sys.version and should be left as is too. Thanks!
encukou commented on Feb 4, 2020
PR for removing __version__ from mock: #17977
furkanonder commented on May 13, 2023
@encukou The issue seems to have been resolved. Can we close the issue?
encukou commented on May 15, 2023
There are still a lot of modules with __version__
IMO, to resolve it properly:
Note that nowadays, the proper way to remove an attribute is with a deprecation period using module __getattr__.
smontanaro commented on Jan 17, 2024
I just migrated __version__ from _csv.c to csv.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 commented on 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 commented on 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 VERSION and a couple of versions 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 commented on 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)