Open warsaw opened 2 years ago
I've removed importlib.utils.set_loader
, importlib.utils.set_package
, and
importlib.utils.module_for_loader
from importlib.utils
in https://github.com/python/cpython/pull/97898 🎉
I've created a PR: https://github.com/python/cpython/pull/98520 to complete these two tasks:
- [ ] pkgutil.find_loader()
- [ ] pkgutil.get_loader() (or it needs to be reimplemented to not use find_loader())
FYI https://github.com/python/cpython/issues/64138 is a tracking issue for pkgutil
all up.
From the meta checklist:
Deprecate pkgutil.find_loader()
I kind of think we're okay here, at least for 3.12. This uses importlib.util.find_spec()
so I feel like it's not so urgent to deprecate and actually probably has some utility.
Deprecate pkgutil.get_loader()
Similarly, I'm not sure this even needs to be deprecated. It is implemented in terms of the above, and thus find_spec()
, and it has some potentially useful wrapper semantics.
I'm going to mark both issues as complete and not deprecate it in 3.12.
@brettcannon @ericsnowcurrently - I think this PR is ready for review. I feel good that we've implemented all the removals we need for 3.12. Like the other issues, we can address the doc updates after beta 1.
The removal branch has been merged, but I'm leaving this meta issue open for now so we can address the documentation checklist during the beta cycle.
Thanks again for tackling this, @warsaw!
[For the imp
module, I created issues for most of the 71 projects in the PyPI top 5k (listed at python/cpython#98573 (comment)), where I could find their tracker. And some already had issues.
I've checked off projects which had already fixed but not yet released, or have fixed since I created the issue, or where the project is unmaintained or otherwise abandoned and a fix is unlikely in any case.
Currently 24/71 (34%) are checked off. In the issue I pointed to the 3.11 imp
docs which have suggestions of how to upgrade each functions/constants, and most seemed fine with that so far, except for one noting imp.load_source
has no suggestions.
_imp
)Edit 2024-10-17: 57/71 (80%)
Due to nose
being unmaintained (number 41 in your list), that's why there's pynose
now (number 55 in your list).
It's a complete drop-in replacement for all occurrences. (Let me know if that isn't the case.)
Edit 2023-11-05: 36/71 (52%)
We're now over 50% of those in the checklist.
Edit 2024-06-07: 55/71 (78%)
We're now at 78% (fixed or unmaintained/abandoned).
This is a meta issue tracking all the things that need to be cleaned up in the import system. From removing long deprecated APIs to migrating internal access to
__spec__
, we'll have several task lists for each related set of clean ups.@brettcannon @ericsnowcurrently for visibility.
Removing deprecated APIs
Over in What's New for Python 3.11 there's a long list of things that have been deprecated long enough that they can be removed in Python 3.12. Here's that task list for tracking purposes. Watch for linked PRs (maybe one big one or many small ones -- we'll see!).
@brettcannon @ericsnowcurrently for visibility.
importlib.util.set_loader_wrapper()
importlib.util.set_package_wrapper()
importlib.machinery.BuiltinImporter.find_module()
importlib.machinery.BuiltinLoader.module_repr()
(3.12: #97876)importlib.machinery.FileFinder.find_module()
importlib.machinery.FrozenImporter.find_module()
importlib.machinery.FrozenLoader.module_repr()
(3.12: #97876)importlib.machinery.WindowsRegistryFinder.find_module()
pkgutil.ImpImporter
(3.12: already deprecated)pkgutil.ImpLoader
imp
module (3.12: #98040)importlib.abc.Finder
Update docs
__main__
is initialized?__main__
quirks/pitfalls (i.e. copy from PEP 395).Missing deprecations
Here's a list of related APIs that have not yet been deprecated, but should be. We'll deprecate them in 3.12 and remove them in 3.14.
pkgutil.find_loader()
pkgutil.get_loader()
(or it needs to be reimplemented to not usefind_loader()
)Other: