From dc0295c235ff81b1b17df046ed5d52889467be59 Mon Sep 17 00:00:00 2001 From: Gouri Jain Date: Sun, 1 Mar 2026 04:36:41 +0530 Subject: [PATCH 1/2] gh-145299: Remove misplaced __cached__ deprecation notice The __cached__ deprecation notice was under __file__ documentation. Since __cached__ was removed in 3.15, the deprecation notice is no longer relevant and has been removed. --- Doc/reference/datamodel.rst | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index cf5a0e71a104eb..d123021d529aaa 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1084,15 +1084,6 @@ this approach. :ref:`import system ` may opt to leave it unset if it has no semantic meaning (for example, a module loaded from a database). - .. deprecated-removed:: 3.13 3.15 - Setting ``__cached__`` on a module while failing to set - :attr:`!__spec__.cached` is deprecated. In Python 3.15, - ``__cached__`` will cease to be set or taken into consideration by - the import system or standard library. - - .. versionchanged:: 3.15 - ``__cached__`` is no longer set. - Other writable attributes on module objects ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From a577b5fba68ca15f7e0f7000cd17b5efe819c2df Mon Sep 17 00:00:00 2001 From: Gouri Jain Date: Mon, 2 Mar 2026 02:03:53 +0530 Subject: [PATCH 2/2] Move __cached__ deprecation to its own section in datamodel.rst --- Doc/reference/datamodel.rst | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index d123021d529aaa..1426e96aae306c 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -923,6 +923,7 @@ Attribute assignment updates the module's namespace dictionary, e.g., single: __loader__ (module attribute) single: __path__ (module attribute) single: __file__ (module attribute) + single: __cached__ (module attribute) single: __doc__ (module attribute) single: __annotations__ (module attribute) single: __annotate__ (module attribute) @@ -1073,8 +1074,7 @@ this approach. .. attribute:: module.__file__ :attr:`!__file__` is an optional attribute that - may or may not be set. Both attributes should be a :class:`str` when they - are available. + may or may not be set. When available, it should be a :class:`str`. An optional attribute, :attr:`!__file__` indicates the pathname of the file from which the module was loaded (if loaded from a file), or the pathname of @@ -1084,6 +1084,18 @@ this approach. :ref:`import system ` may opt to leave it unset if it has no semantic meaning (for example, a module loaded from a database). +.. attribute:: module.__cached__ + + An optional attribute, :attr:`!__cached__` indicates the pathname of the + compiled bytecode file. + + .. deprecated-removed:: 3.12 3.15 + Setting ``__cached__`` is deprecated. In Python 3.15, + ``__cached__`` will cease to be set or taken into consideration by + the import system or standard library. + See :attr:`module.__spec__.cached ` + instead. + Other writable attributes on module objects ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^