]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-76007: Deprecate `__version__` attribute (#138675)
authorHugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Mon, 29 Sep 2025 09:03:23 +0000 (11:03 +0200)
committerGitHub <noreply@github.com>
Mon, 29 Sep 2025 09:03:23 +0000 (12:03 +0300)
Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
34 files changed:
Doc/deprecations/index.rst
Doc/deprecations/pending-removal-in-3.20.rst [new file with mode: 0644]
Doc/whatsnew/3.12.rst
Doc/whatsnew/3.13.rst
Doc/whatsnew/3.14.rst
Doc/whatsnew/3.15.rst
Lib/argparse.py
Lib/csv.py
Lib/ctypes/macholib/__init__.py
Lib/ipaddress.py
Lib/json/__init__.py
Lib/logging/__init__.py
Lib/optparse.py
Lib/pickle.py
Lib/platform.py
Lib/re/__init__.py
Lib/socketserver.py
Lib/tabnanny.py
Lib/test/test_argparse.py
Lib/test/test_csv.py
Lib/test/test_ctypes/test_macholib.py
Lib/test/test_ipaddress.py
Lib/test/test_json/__init__.py
Lib/test/test_logging.py
Lib/test/test_optparse.py
Lib/test/test_re.py
Lib/test/test_socketserver.py
Lib/test/test_tabnanny.py
Lib/test/test_tkinter/test_font.py
Lib/test/test_ttk/__init__.py
Lib/tkinter/font.py
Lib/tkinter/ttk.py
Misc/NEWS.d/next/Library/2025-09-08-17-32-02.gh-issue-76007.peEgcr.rst [new file with mode: 0644]
Misc/sbom.spdx.json

index c6e05c176b2aa1764261cfa018aeb88ab2cfe500..f3cecb321d633fdfeeb13a6d90386a907f170db0 100644 (file)
@@ -9,6 +9,8 @@ Deprecations
 
 .. include:: pending-removal-in-3.19.rst
 
+.. include:: pending-removal-in-3.20.rst
+
 .. include:: pending-removal-in-future.rst
 
 C API deprecations
diff --git a/Doc/deprecations/pending-removal-in-3.20.rst b/Doc/deprecations/pending-removal-in-3.20.rst
new file mode 100644 (file)
index 0000000..8bc863b
--- /dev/null
@@ -0,0 +1,23 @@
+Pending removal in Python 3.20
+------------------------------
+
+* The ``__version__`` attribute has been deprecated in these standard library
+  modules and will be removed in Python 3.20.
+  Use :py:data:`sys.version_info` instead.
+
+  - :mod:`argparse`
+  - :mod:`csv`
+  - :mod:`!ctypes.macholib`
+  - :mod:`ipaddress`
+  - :mod:`json`
+  - :mod:`logging` (``__date__`` also deprecated)
+  - :mod:`optparse`
+  - :mod:`pickle`
+  - :mod:`platform`
+  - :mod:`re`
+  - :mod:`socketserver`
+  - :mod:`tabnanny`
+  - :mod:`tkinter.font`
+  - :mod:`tkinter.ttk`
+
+  (Contributed by Hugo van Kemenade in :gh:`76007`.)
index 2b6939cd323dcf70be22f632918566e155770799..8badfe9a6b49b95c4f46a82d7f78746b9204844d 100644 (file)
@@ -1363,6 +1363,10 @@ Deprecated
 
 .. include:: ../deprecations/pending-removal-in-3.17.rst
 
+.. include:: ../deprecations/pending-removal-in-3.19.rst
+
+.. include:: ../deprecations/pending-removal-in-3.20.rst
+
 .. include:: ../deprecations/pending-removal-in-future.rst
 
 .. _whatsnew312-removed:
index fbb27adbf9969c23ea8b03cbf8cca83b707cada3..bc5a21e172d0bc899014c57f560fb3ebed62e13d 100644 (file)
@@ -2026,6 +2026,10 @@ New Deprecations
 
 .. include:: ../deprecations/pending-removal-in-3.17.rst
 
+.. include:: ../deprecations/pending-removal-in-3.19.rst
+
+.. include:: ../deprecations/pending-removal-in-3.20.rst
+
 .. include:: ../deprecations/pending-removal-in-future.rst
 
 CPython Bytecode Changes
index caeff3a00aa04923e7d43eb5c4d9045b5e72b991..102d8ee9830a92e46813c285f2cbad0b85d74cb6 100644 (file)
@@ -2794,6 +2794,8 @@ Deprecated
 
 .. include:: ../deprecations/pending-removal-in-3.19.rst
 
+.. include:: ../deprecations/pending-removal-in-3.20.rst
+
 .. include:: ../deprecations/pending-removal-in-future.rst
 
 
index d8c5d9378008eb88c0effd82237f14842745dcd0..4b176d6c8e60340994d0c87f5d252294622956a2 100644 (file)
@@ -631,9 +631,42 @@ hashlib
 
   (Contributed by Bénédikt Tran in :gh:`134978`.)
 
+__version__
+-----------
+
+* The ``__version__`` attribute has been deprecated in these standard library
+  modules and will be removed in Python 3.20.
+  Use :py:data:`sys.version_info` instead.
+
+  - :mod:`argparse`
+  - :mod:`csv`
+  - :mod:`!ctypes.macholib`
+  - :mod:`ipaddress`
+  - :mod:`json`
+  - :mod:`logging` (``__date__`` also deprecated)
+  - :mod:`optparse`
+  - :mod:`pickle`
+  - :mod:`platform`
+  - :mod:`re`
+  - :mod:`socketserver`
+  - :mod:`tabnanny`
+  - :mod:`tkinter.font`
+  - :mod:`tkinter.ttk`
+
+  (Contributed by Hugo van Kemenade in :gh:`76007`.)
 
 .. Add deprecations above alphabetically, not here at the end.
 
+.. include:: ../deprecations/pending-removal-in-3.16.rst
+
+.. include:: ../deprecations/pending-removal-in-3.17.rst
+
+.. include:: ../deprecations/pending-removal-in-3.19.rst
+
+.. include:: ../deprecations/pending-removal-in-3.20.rst
+
+.. include:: ../deprecations/pending-removal-in-future.rst
+
 Removed
 =======
 
index 2144c81886ad19fbe707b0f857b7fbdedc3a7d0f..863e951528b6d014b97aeabe1852f98d77b89625 100644 (file)
@@ -64,7 +64,6 @@ considered public as object names -- the API of the formatter objects is
 still considered an implementation detail.)
 """
 
-__version__ = '1.1'
 __all__ = [
     'ArgumentParser',
     'ArgumentError',
@@ -2773,3 +2772,12 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
     def _warning(self, message):
         args = {'prog': self.prog, 'message': message}
         self._print_message(_('%(prog)s: warning: %(message)s\n') % args, _sys.stderr)
+
+
+def __getattr__(name):
+    if name == "__version__":
+        from warnings import _deprecated
+
+        _deprecated("__version__", remove=(3, 20))
+        return "1.1"  # Do not change
+    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
index 0a627ba7a512fa8ab84dc9d442d5724bf2eaf9f2..98eab01429a8ec10daa5ef5e4262c17604bcff16 100644 (file)
@@ -81,8 +81,6 @@ __all__ = ["QUOTE_MINIMAL", "QUOTE_ALL", "QUOTE_NONNUMERIC", "QUOTE_NONE",
            "unregister_dialect", "DictReader", "DictWriter",
            "unix_dialect"]
 
-__version__ = "1.0"
-
 
 class Dialect:
     """Describe a CSV dialect.
@@ -511,3 +509,12 @@ class Sniffer:
                     hasHeader -= 1
 
         return hasHeader > 0
+
+
+def __getattr__(name):
+    if name == "__version__":
+        from warnings import _deprecated
+
+        _deprecated("__version__", remove=(3, 20))
+        return "1.0"  # Do not change
+    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
index 5621defccd61d1c4b0c64b8e136ef4357052dcb3..f00e55f8131c9d00f4221ec344c6893bda21b4d4 100644 (file)
@@ -6,4 +6,10 @@ See the relevant header files in /usr/include/mach-o
 And also Apple's documentation.
 """
 
-__version__ = '1.0'
+def __getattr__(name):
+    if name == "__version__":
+        from warnings import _deprecated
+
+        _deprecated("__version__", remove=(3, 20))
+        return "1.0"  # Do not change
+    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
index 7470dc6c52d3a8ba2cfb60ee2045dfc8d4dc9178..aa0cf4a0620cd0e00aeb96c675dd7866aafa474a 100644 (file)
@@ -8,9 +8,6 @@ and networks.
 
 """
 
-__version__ = '1.0'
-
-
 import functools
 
 IPV4LENGTH = 32
@@ -2419,3 +2416,12 @@ class _IPv6Constants:
 
 IPv6Address._constants = _IPv6Constants
 IPv6Network._constants = _IPv6Constants
+
+
+def __getattr__(name):
+    if name == "__version__":
+        from warnings import _deprecated
+
+        _deprecated("__version__", remove=(3, 20))
+        return "1.0"  # Do not change
+    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
index 1d972d22ded072a0a4c9b1d2cfabe3552d25fcc2..c8fdd0d99a0efc36684e0100fcb36ddb9f1ae8ff 100644 (file)
@@ -95,7 +95,6 @@ Using json from the shell to validate and pretty-print::
     $ echo '{ 1.2:3.4}' | python -m json
     Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
 """
-__version__ = '2.0.9'
 __all__ = [
     'dump', 'dumps', 'load', 'loads',
     'JSONDecoder', 'JSONDecodeError', 'JSONEncoder',
@@ -357,3 +356,12 @@ def loads(s, *, cls=None, object_hook=None, parse_float=None,
     if parse_constant is not None:
         kw['parse_constant'] = parse_constant
     return cls(**kw).decode(s)
+
+
+def __getattr__(name):
+    if name == "__version__":
+        from warnings import _deprecated
+
+        _deprecated("__version__", remove=(3, 20))
+        return "2.0.9"  # Do not change
+    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
index c5860d53b1bdffca284ffad6693020a17882e01c..431ff41b352048b41e43a1f93fab5a04c7b6b081 100644 (file)
@@ -45,9 +45,6 @@ import threading
 
 __author__  = "Vinay Sajip <vinay_sajip@red-dove.com>"
 __status__  = "production"
-# The following module attributes are no longer updated.
-__version__ = "0.5.1.2"
-__date__    = "07 February 2010"
 
 #---------------------------------------------------------------------------
 #   Miscellaneous module data
@@ -2341,3 +2338,16 @@ def captureWarnings(capture):
         if _warnings_showwarning is not None:
             warnings.showwarning = _warnings_showwarning
             _warnings_showwarning = None
+
+
+def __getattr__(name):
+    if name in ("__version__", "__date__"):
+        from warnings import _deprecated
+
+        _deprecated(name, remove=(3, 20))
+        return {  # Do not change
+            "__version__": "0.5.1.2",
+            "__date__": "07 February 2010",
+        }[name]
+
+    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
index 38cf16d21efffa658c0ef3fa81bb1f9fc3306a29..02ff7140882ed641e24abda2afb1aaa5c612bdcd 100644 (file)
@@ -21,8 +21,6 @@ Simple usage example:
    (options, args) = parser.parse_args()
 """
 
-__version__ = "1.5.3"
-
 __all__ = ['Option',
            'make_option',
            'SUPPRESS_HELP',
@@ -1669,3 +1667,12 @@ def _match_abbrev(s, wordmap):
 # which will become a factory function when there are many Option
 # classes.
 make_option = Option
+
+
+def __getattr__(name):
+    if name == "__version__":
+        from warnings import _deprecated
+
+        _deprecated("__version__", remove=(3, 20))
+        return "1.5.3"  # Do not change
+    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
index beaefae0479d3ca15347f6b1393b57e19c01b2ef..729c215514ad24078619d11a0aae4b0a9738b479 100644 (file)
@@ -17,7 +17,6 @@ Functions:
 
 Misc variables:
 
-    __version__
     format_version
     compatible_formats
 
index 4028012dc3ce6adc7d8b10ccdbc1dcbe5310e977..4db93bea2a39e1ed6fab10e5b182573d3cac876d 100644 (file)
@@ -110,8 +110,6 @@ __copyright__ = """
 
 """
 
-__version__ = '1.1.0'
-
 import collections
 import os
 import re
@@ -1436,5 +1434,14 @@ def _main(args: list[str] | None = None):
     print(platform(aliased, terse))
 
 
+def __getattr__(name):
+    if name == "__version__":
+        from warnings import _deprecated
+
+        _deprecated("__version__", remove=(3, 20))
+        return "1.1.0"  # Do not change
+    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
+
+
 if __name__ == "__main__":
     _main()
index af2808a77da69152b32aafb5a5c941d076921bc4..a5316391297f4c95cdd9341c9606b42f983bc8eb 100644 (file)
@@ -137,8 +137,6 @@ __all__ = [
     "UNICODE", "NOFLAG", "RegexFlag", "PatternError"
 ]
 
-__version__ = "2.2.1"
-
 @enum.global_enum
 @enum._simple_enum(enum.IntFlag, boundary=enum.KEEP)
 class RegexFlag:
@@ -426,3 +424,12 @@ class Scanner:
                 append(action)
             i = j
         return result, string[i:]
+
+
+def __getattr__(name):
+    if name == "__version__":
+        from warnings import _deprecated
+
+        _deprecated("__version__", remove=(3, 20))
+        return "2.2.1"  # Do not change
+    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
index 93b0a23be27f6808645b344c383336841eb8a20b..ec389457ef5b1c145b239ca71bd5aa6eb448bffd 100644 (file)
@@ -120,9 +120,6 @@ BaseServer:
 
 # Author of the BaseServer patch: Luke Kenneth Casson Leighton
 
-__version__ = "0.4"
-
-
 import socket
 import selectors
 import os
@@ -861,3 +858,12 @@ class DatagramRequestHandler(BaseRequestHandler):
 
     def finish(self):
         self.socket.sendto(self.wfile.getvalue(), self.client_address)
+
+
+def __getattr__(name):
+    if name == "__version__":
+        from warnings import _deprecated
+
+        _deprecated("__version__", remove=(3, 20))
+        return "0.4"  # Do not change
+    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
index c0097351b269f2c7f3f7425e3fdbe49622c1a5cf..272e8e33e0c46a9b428cbbdf83eee4ae7ee07918 100644 (file)
@@ -16,8 +16,6 @@ releases; such changes may not be backward compatible.
 # XXX The API needs to undergo changes however; the current code is too
 # XXX script-like.  This will be addressed later.
 
-__version__ = "6"
-
 import os
 import sys
 import tokenize
@@ -334,5 +332,14 @@ def _process_tokens(tokens):
                 raise NannyNag(start[0], msg, line)
 
 
+def __getattr__(name):
+    if name == "__version__":
+        from warnings import _deprecated
+
+        _deprecated("__version__", remove=(3, 20))
+        return "6"  # Do not change
+    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
+
+
 if __name__ == '__main__':
     main()
index fc73174d98cd6f506ddefe6303fa97f40f6e3883..90bfcd0ae3e29b8a03e16409dc6f71612669f8da 100644 (file)
@@ -7356,6 +7356,16 @@ class TestColorized(TestCase):
         '''))
 
 
+class TestModule(unittest.TestCase):
+    def test_deprecated__version__(self):
+        with self.assertWarnsRegex(
+            DeprecationWarning,
+            "'__version__' is deprecated and slated for removal in Python 3.20",
+        ) as cm:
+            getattr(argparse, "__version__")
+        self.assertEqual(cm.filename, __file__)
+
+
 def tearDownModule():
     # Remove global references to avoid looking like we have refleaks.
     RFile.seen = {}
index 60feab225a107cdb33fecc2821974594086345c1..50431b562f90bafb72f54e1a42e7cda661cb42b4 100644 (file)
@@ -1603,5 +1603,16 @@ class MiscTestCase(unittest.TestCase):
             with self.subTest(tp=tp):
                 check_disallow_instantiation(self, tp)
 
+
+class TestModule(unittest.TestCase):
+    def test_deprecated__version__(self):
+        with self.assertWarnsRegex(
+            DeprecationWarning,
+            "'__version__' is deprecated and slated for removal in Python 3.20",
+        ) as cm:
+            getattr(csv, "__version__")
+        self.assertEqual(cm.filename, __file__)
+
+
 if __name__ == '__main__':
     unittest.main()
index 9d90617995623d1f3b647a303d49dcef0aa4c624..9a5e18ed589d44bd416d5c18531758605ea81577 100644 (file)
@@ -108,5 +108,17 @@ class MachOTest(unittest.TestCase):
                          d('P', 'F.framework/Versions/A/F_debug', 'F', 'A', 'debug'))
 
 
+class TestModule(unittest.TestCase):
+    def test_deprecated__version__(self):
+        import ctypes.macholib
+
+        with self.assertWarnsRegex(
+            DeprecationWarning,
+            "'__version__' is deprecated and slated for removal in Python 3.20",
+        ) as cm:
+            getattr(ctypes.macholib, "__version__")
+        self.assertEqual(cm.filename, __file__)
+
+
 if __name__ == "__main__":
     unittest.main()
index 62929f9dd68b5afefd00b7b042f88c1cf867b53e..11721a59972672d4334c9d1ae7f3f94139678d0b 100644 (file)
@@ -2821,5 +2821,15 @@ class IpaddrUnitTest(unittest.TestCase):
         )
 
 
+class TestModule(unittest.TestCase):
+    def test_deprecated__version__(self):
+        with self.assertWarnsRegex(
+            DeprecationWarning,
+            "'__version__' is deprecated and slated for removal in Python 3.20",
+        ) as cm:
+            getattr(ipaddress, "__version__")
+        self.assertEqual(cm.filename, __file__)
+
+
 if __name__ == '__main__':
     unittest.main()
index 74b64ed86a3183db5a54166d89cf2fb227281e06..e58fbee41af3e6cb50ee4d37bd14a16e1e8e82ce 100644 (file)
@@ -47,6 +47,16 @@ class TestCTest(CTest):
                          '_json')
 
 
+class TestModule(unittest.TestCase):
+    def test_deprecated__version__(self):
+        with self.assertWarnsRegex(
+            DeprecationWarning,
+            "'__version__' is deprecated and slated for removal in Python 3.20",
+        ) as cm:
+            getattr(json, "__version__")
+        self.assertEqual(cm.filename, __file__)
+
+
 def load_tests(loader, _, pattern):
     suite = unittest.TestSuite()
     for mod in (json, json.encoder, json.decoder):
index 7a08f9ec9de9fb8505e840c6d73ee7576a7f7341..1f7a4d9e197f9c4f8764b799e0d99448cf3e75e0 100644 (file)
@@ -7236,6 +7236,16 @@ class MiscTestCase(unittest.TestCase):
         support.check__all__(self, logging, not_exported=not_exported)
 
 
+class TestModule(unittest.TestCase):
+    def test_deprecated__version__and__date__(self):
+        msg = "is deprecated and slated for removal in Python 3.20"
+        for attr in ("__version__", "__date__"):
+            with self.subTest(attr=attr):
+                with self.assertWarnsRegex(DeprecationWarning, msg) as cm:
+                    getattr(logging, attr)
+                self.assertEqual(cm.filename, __file__)
+
+
 # Set the locale to the platform-dependent default.  I have no idea
 # why the test does this, but in any case we save the current locale
 # first and restore it at the end.
index e476e4727803e5e7e756a3265c5d55ef45f56555..fc8ef9520b3c0f39295acf974a9011be2465ab9b 100644 (file)
@@ -1666,6 +1666,16 @@ class TestTranslations(TestTranslationsBase):
         self.assertMsgidsEqual(optparse)
 
 
+class TestModule(unittest.TestCase):
+    def test_deprecated__version__(self):
+        with self.assertWarnsRegex(
+            DeprecationWarning,
+            "'__version__' is deprecated and slated for removal in Python 3.20",
+        ) as cm:
+            getattr(optparse, "__version__")
+        self.assertEqual(cm.filename, __file__)
+
+
 if __name__ == '__main__':
     # To regenerate translation snapshots
     if len(sys.argv) > 1 and sys.argv[1] == '--snapshot-update':
index d4a2863728e1f8d5512f53ba9c85579f2029e4ec..5fc95087f2b6addde948b525d5f526bd5caea1fc 100644 (file)
@@ -3116,5 +3116,15 @@ class ExternalTests(unittest.TestCase):
                     self.assertTrue(obj.search(s))
 
 
+class TestModule(unittest.TestCase):
+    def test_deprecated__version__(self):
+        with self.assertWarnsRegex(
+            DeprecationWarning,
+            "'__version__' is deprecated and slated for removal in Python 3.20",
+        ) as cm:
+            getattr(re, "__version__")
+        self.assertEqual(cm.filename, __file__)
+
+
 if __name__ == "__main__":
     unittest.main()
index 893372cbbd0be9064cc8d25a54ebe4fafb2bdadb..a5e03020e5bd5712430c784f230dc60bd3043ad0 100644 (file)
@@ -511,5 +511,15 @@ class MiscTestCase(unittest.TestCase):
         server.server_close()
 
 
+class TestModule(unittest.TestCase):
+    def test_deprecated__version__(self):
+        with self.assertWarnsRegex(
+            DeprecationWarning,
+            "'__version__' is deprecated and slated for removal in Python 3.20",
+        ) as cm:
+            getattr(socketserver, "__version__")
+        self.assertEqual(cm.filename, __file__)
+
+
 if __name__ == "__main__":
     unittest.main()
index 30dcb3e3c4f4f95b9bc38e89a8dd1f7ba9530029..e575aac037e917289bf10e77f39665cdff0f4452 100644 (file)
@@ -3,7 +3,8 @@
 Glossary:
     * errored    : Whitespace related problems present in file.
 """
-from unittest import TestCase, mock
+
+from unittest import TestCase, main, mock
 import errno
 import os
 import tabnanny
@@ -352,3 +353,17 @@ class TestCommandLine(TestCase):
                 "offending line: '\\tprint(\"world\")'"
             ).strip()
             self.validate_cmd("-vv", path, stdout=stdout, partial=True)
+
+
+class TestModule(TestCase):
+    def test_deprecated__version__(self):
+        with self.assertWarnsRegex(
+            DeprecationWarning,
+            "'__version__' is deprecated and slated for removal in Python 3.20",
+        ) as cm:
+            getattr(tabnanny, "__version__")
+        self.assertEqual(cm.filename, __file__)
+
+
+if __name__ == "__main__":
+    main()
index 563707ddd2fa9b9d5d48cf9e673b2a12d7313cbe..3616da54cf7075d8d1dfcc827e567b3aafe3cba0 100644 (file)
@@ -159,5 +159,15 @@ class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):
         self.assertRaises(RuntimeError, font.nametofont, fontname)
 
 
+class TestModule(unittest.TestCase):
+    def test_deprecated__version__(self):
+        with self.assertWarnsRegex(
+            DeprecationWarning,
+            "'__version__' is deprecated and slated for removal in Python 3.20",
+        ) as cm:
+            getattr(font, "__version__")
+        self.assertEqual(cm.filename, __file__)
+
+
 if __name__ == "__main__":
     unittest.main()
index 7ee7ffbd6d74086a6ca80df1666bfeeb84493d21..4a077a0f966fbb3ac13dc0e21e16813fe0001c79 100644 (file)
@@ -19,6 +19,16 @@ from _tkinter import TclError
 from tkinter import ttk
 
 
+class TestModule(unittest.TestCase):
+    def test_deprecated__version__(self):
+        with self.assertWarnsRegex(
+            DeprecationWarning,
+            "'__version__' is deprecated and slated for removal in Python 3.20",
+        ) as cm:
+            getattr(ttk, "__version__")
+        self.assertEqual(cm.filename, __file__)
+
+
 def setUpModule():
     root = None
     try:
index 3e24e28ef58cde90dafe78016ce38867a008b450..7aed523cce3784b9a2fd72bceebe9d0adeb8730c 100644 (file)
@@ -6,7 +6,6 @@
 import itertools
 import tkinter
 
-__version__ = "0.9"
 __all__ = ["NORMAL", "ROMAN", "BOLD", "ITALIC",
            "nametofont", "Font", "families", "names"]
 
@@ -198,6 +197,15 @@ def names(root=None):
     return root.tk.splitlist(root.tk.call("font", "names"))
 
 
+def __getattr__(name):
+    if name == "__version__":
+        from warnings import _deprecated
+
+        _deprecated("__version__", remove=(3, 20))
+        return "0.9"  # Do not change
+    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
+
+
 # --------------------------------------------------------------------
 # test stuff
 
index ef2b91dfbb66388fdc89b4d01ef2a10b64d6920f..5c5ef11ae05ba6ec998fa6c1c7aaa144473f9838 100644 (file)
@@ -12,8 +12,6 @@ maintaining the widget state and invoking callbacks, all aspects
 of the widgets appearance lies at Themes.
 """
 
-__version__ = "0.3.1"
-
 __author__ = "Guilherme Polo <ggpolo@gmail.com>"
 
 __all__ = ["Button", "Checkbutton", "Combobox", "Entry", "Frame", "Label",
@@ -1648,3 +1646,12 @@ class OptionMenu(Menubutton):
         except AttributeError:
             pass
         super().destroy()
+
+
+def __getattr__(name):
+    if name == "__version__":
+        from warnings import _deprecated
+
+        _deprecated("__version__", remove=(3, 20))
+        return "0.3.1"  # Do not change
+    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
diff --git a/Misc/NEWS.d/next/Library/2025-09-08-17-32-02.gh-issue-76007.peEgcr.rst b/Misc/NEWS.d/next/Library/2025-09-08-17-32-02.gh-issue-76007.peEgcr.rst
new file mode 100644 (file)
index 0000000..c6476f0
--- /dev/null
@@ -0,0 +1,2 @@
+Deprecate ``__version__`` from a number of standard library modules. Patch
+by Hugo van Kemenade.
index 6ca09684a595a013f9c4cd91aa74370b1b418be7..dc5497663a95bcc7f3a80ab4d2f2ba4c75584935 100644 (file)
       "checksums": [
         {
           "algorithm": "SHA1",
-          "checksumValue": "0fbc026a9771d9675e7094790b5b945334d3cb53"
+          "checksumValue": "0d83ed429ede0a2c6617cd2f24490be16d8393f4"
         },
         {
           "algorithm": "SHA256",
-          "checksumValue": "1e77c01eec8f167ed10b754f153c0c743c8e5196ae9c81dffc08f129ab56dbfd"
+          "checksumValue": "876f4486d08d3eac3581a8681d7fb3cec2fe5b823d1bef27cca15e755510365c"
         }
       ],
       "fileName": "Lib/ctypes/macholib/__init__.py"