Skip to content

Commit 910612e

Browse files
committed
gh-65961: Document __cached__ removal in What's New & clarify references to it
- Move deprecation notice to change list - Clarify references to ``__cached__`` now that the term it doesn't link to its docs. - Move the ``.. versionchanged`` from ``__file__`` docs to the top level.
1 parent c612fd4 commit 910612e

5 files changed

Lines changed: 15 additions & 19 deletions

File tree

Doc/c-api/import.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Importing Modules
146146
alternatives.
147147
148148
.. versionchanged:: 3.15
149-
``__cached__`` is no longer set.
149+
The ``__cached__`` attribute is no longer set.
150150
151151
152152
.. c:function:: PyObject* PyImport_ExecCodeModuleEx(const char *name, PyObject *co, const char *pathname)
@@ -170,7 +170,7 @@ Importing Modules
170170
:class:`~importlib.machinery.ModuleSpec` for alternatives.
171171
172172
.. versionchanged:: 3.15
173-
``__cached__`` no longer set.
173+
The ``__cached__`` attribute no longer set.
174174
175175
176176
.. c:function:: PyObject* PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co, const char *pathname, const char *cpathname)

Doc/deprecations/pending-removal-in-3.15.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
Pending removal in Python 3.15
22
------------------------------
33

4-
* The import system:
5-
6-
* Setting ``__cached__`` on a module while
7-
failing to set :attr:`__spec__.cached <importlib.machinery.ModuleSpec.cached>`
8-
is deprecated. In Python 3.15, ``__cached__`` will cease to be set or
9-
take into consideration by the import system or standard library. (:gh:`97879`)
10-
114
* :mod:`ctypes`:
125

136
* The undocumented :func:`!ctypes.SetPointerType` function

Doc/library/runpy.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ The :mod:`!runpy` module provides two functions:
9797
:class:`~importlib.machinery.ModuleSpec` for alternatives.
9898

9999
.. versionchanged:: 3.15
100-
``__cached__`` is no longer set.
100+
The global variable ``__cached__`` is no longer set.
101101

102102
.. function:: run_path(path_name, init_globals=None, run_name=None)
103103

@@ -175,7 +175,7 @@ The :mod:`!runpy` module provides two functions:
175175
``__package__`` are deprecated.
176176

177177
.. versionchanged:: 3.15
178-
``__cached__`` is no longer set.
178+
The global variable ``__cached__`` is no longer set.
179179

180180
.. seealso::
181181

Doc/reference/datamodel.rst

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,14 +1099,9 @@ this approach.
10991099
:ref:`import system <importsystem>` may opt to leave it unset if it
11001100
has no semantic meaning (for example, a module loaded from a database).
11011101

1102-
.. deprecated-removed:: 3.13 3.15
1103-
Setting ``__cached__`` on a module while failing to set
1104-
:attr:`!__spec__.cached` is deprecated. In Python 3.15,
1105-
``__cached__`` will cease to be set or taken into consideration by
1106-
the import system or standard library.
1107-
1108-
.. versionchanged:: 3.15
1109-
``__cached__`` is no longer set.
1102+
.. versionchanged:: 3.15
1103+
The ``__cached__`` attribute is no longer set on modules or taken into
1104+
consideration by the import system or standard library.
11101105

11111106
Other writable attributes on module objects
11121107
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Doc/whatsnew/3.15.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,14 @@ Other language changes
880880
other, as regular dynamic extensions do.
881881
(Contributed by Stefano Rivera in :gh:`122931`.)
882882

883+
* The ``__cached__`` attribute on modules, which was deprecated since version
884+
3.13, is no longer set or taken into consideration by the import system or
885+
standard library.
886+
Use :attr:`__spec__.cached <importlib.machinery.ModuleSpec.cached>` instead.
887+
(Contributed by Brett Cannon in :gh:`97879`)
888+
889+
Note that the :attr:`~module.__loader__` and :attr:`~module.__package__`
890+
attributes are also deprecated and scheduled for removal.
883891

884892

885893
Default interactive shell

0 commit comments

Comments
 (0)