gh-65961: Do not rely solely on __cached__ (GH-97990)

Make sure `__spec__.cached` (at minimum) can be used.
This commit is contained in:
Brett Cannon 2022-10-06 15:40:22 -07:00 committed by GitHub
parent f8edc6ff53
commit e1c4d56fdd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 130 additions and 35 deletions

View file

@ -150,6 +150,11 @@ Importing Modules
See also :c:func:`PyImport_ExecCodeModuleEx` and
:c:func:`PyImport_ExecCodeModuleWithPathnames`.
.. versionchanged:: 3.12
The setting of :attr:`__cached__` and :attr:`__loader__` is
deprecated. See :class:`~importlib.machinery.ModuleSpec` for
alternatives.
.. c:function:: PyObject* PyImport_ExecCodeModuleEx(const char *name, PyObject *co, const char *pathname)
@ -167,6 +172,10 @@ Importing Modules
.. versionadded:: 3.3
.. versionchanged:: 3.12
Setting :attr:`__cached__` is deprecated. See
:class:`~importlib.machinery.ModuleSpec` for alternatives.
.. c:function:: PyObject* PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co, const char *pathname, const char *cpathname)