Skip to content

GH-65961: Stop setting __cached__ on modules#142165

Merged
brettcannon merged 4 commits intopython:mainfrom
brettcannon:remove-__cached__
Dec 11, 2025
Merged

GH-65961: Stop setting __cached__ on modules#142165
brettcannon merged 4 commits intopython:mainfrom
brettcannon:remove-__cached__

Conversation

@brettcannon
Copy link
Member

@brettcannon brettcannon commented Dec 1, 2025

@brettcannon brettcannon self-assigned this Dec 2, 2025
@brettcannon brettcannon merged commit af18572 into python:main Dec 11, 2025
118 of 124 checks passed
@brettcannon brettcannon deleted the remove-__cached__ branch December 11, 2025 19:44
fatelei pushed a commit to fatelei/cpython that referenced this pull request Dec 12, 2025
Copy link

@DimitriPapadopoulos DimitriPapadopoulos left a comment

Choose a reason for hiding this comment

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

@brettcannon This change puts the __cached__ deprecation notices under the __file__ attribute. I find this confusing::

Image

instead of :attr:`!module.__path__`.

.. attribute:: module.__file__
.. attribute:: module.__cached__
Copy link

@DimitriPapadopoulos DimitriPapadopoulos Feb 26, 2026

Choose a reason for hiding this comment

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

I can understand why module.__cached__ is removed here, but __cached__ remains implicitly referred to in ensuing deprecation notices.

:attr:`module.__spec__.cached <importlib.machinery.ModuleSpec.cached>`
instead of :attr:`!module.__cached__`.

.. deprecated-removed:: 3.13 3.15

Choose a reason for hiding this comment

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

Perhaps reintroduce attribute module.__cached__ here, or move the __cached__ deprecation notices elsewhere, not under module.__file__.

@brettcannon
Copy link
Member Author

This change puts the __cached__ deprecation notices under the __file__ attribute. I find this confusing

That's a syntax mistake in the docs. Can you please open an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants