GeezerVison is showing github.com — Misleading __version__ attribute of modules in standard library · Issue #76007 · python/cpython
Misleading __version__ attribute of modules in standard library #76007Description
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
Activityabukaj commented on Oct 20, 2017 MannequinAuthor More actions 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.0
while 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:
- There should be a test, similar to
test___all__, to avoid regressions
- For modules where
__version__ has a meaning, that fact should be documented -- either we want users to use it, or there's no point exposing it
Note that nowadays, the proper way to remove an attribute is with a deprecation period using module __getattr__. Reacted by Erlend E. Aasland and Hugo van Kemenade 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
Note that nowadays, the proper way to remove an attribute is with a deprecation period using module __getattr__.
Related issue:
added 2 commits that reference this issue on Dec 13, 2025gh-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:
Thoughts? Reacted by Victor Stinner added a commit that references this issue on Dec 16, 2025gh-76007: Deprecate `__version__` attribute in `wsgiref.simple_server` ( hugovk commented on Dec 17, 2025
There's also a VERSION and a couple of versions we could deprecate:
PR #142898 for that, to close this issue. added a commit that references this issue on Dec 18, 2025gh-76007: Deprecate `VERSION` in `xml.etree.ElementTree` & `version` …
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|