Skip to content

Remove support for __cached__ and __package__ if missing corresponding __spec__ attributes #134088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
picnixz opened this issue May 16, 2025 · 4 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) stdlib Python modules in the Lib dir topic-importlib type-feature A feature request or enhancement

Comments

@picnixz
Copy link
Member

picnixz commented May 16, 2025

Feature or enhancement

Setting __cached__ or __package__ on a module while failing to set the corresponding __spec__ attributes is deprecated since Python 3.12 (see #97879).

cc @brettcannon

@picnixz picnixz added type-feature A feature request or enhancement interpreter-core (Objects, Python, Grammar, and Parser dirs) stdlib Python modules in the Lib dir topic-importlib labels May 16, 2025
@mkaraev

This comment has been minimized.

@picnixz

This comment has been minimized.

@xuantengh
Copy link
Contributor

xuantengh commented May 20, 2025

Hi I'd like to work on this. Does it mean for modules without __spec__, we do not set __cached__ nor __package__ for them?

@picnixz
Copy link
Member Author

picnixz commented May 20, 2025

No my bad, the title is misleading :') it's only if setting the attribute on __spec__ failed that we would not allow setting it otherwise. The exact description is in pending-removal-in-315 but I would like the feedback from an importlib expert.

@picnixz picnixz changed the title Remove support for __cached__ and __package__ on specless modules Remove support for __cached__ and __package__ if missing corresponding __spec__ attributes May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) stdlib Python modules in the Lib dir topic-importlib type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants