Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1084,14 +1084,12 @@ this approach.
:ref:`import system <importsystem>` 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.
.. attribute:: module.__cached__

The ``__cached__`` attribute stores the path to the compiled byte‑code file for a module.
It is deprecated and will be removed in Python 3.15.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes no sense for the 3.15 docs, it has been removed?



.. versionchanged:: 3.15
``__cached__`` is no longer set.

Other writable attributes on module objects
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
16 changes: 16 additions & 0 deletions Lib/test/test_import/test_lazy_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ def test_basic_used(self):
import test.test_import.data.lazy_imports.basic_used
self.assertIn("test.test_import.data.lazy_imports.basic2", sys.modules)

def test_lazy_import_with_getattr(self):
"""Lazy imports work with module __getattr__ (gh-144957)."""
code = textwrap.dedent("""
import sys
sys.set_lazy_imports("normal")
lazy from typing import Match
print(Match)
""")
result = subprocess.run(
[sys.executable, "-c", code],
capture_output=True,
text=True
)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertIn("typing.Match", result.stdout)


class GlobalLazyImportModeTests(unittest.TestCase):
"""Tests for sys.set_lazy_imports() global mode control."""
Expand Down
Loading