Make sure all deprecated items in importlib raise `DeprecationWarning`
- [ ]
importlib.abc.Loader - [ ]
importlib.abc.ResourceLoader - [ ]
importlib.abc.SourceLoader.path_mtime() - [ ]
importlib.machinery.DEBUG_BYTECODE_SUFFIXES - [ ]
importlib.machinery.OPTIMIZED_BYTECODE_SUFFIXES - [ ]
importlib.machinery.WindowsRegistryFinder - [ ]
debug_overrideparameter ofimportlib.util.cache_from_source()
Linked PRs
- gh-121765
I will try this one at europython :)
@rashansmith
To add deprecation warnings to module-level constants like DEBUG_BYTECODE_SUFFIXES I think you can use something like this:
https://github.com/python/cpython/blob/4e36dd7d87eb0f1bd1ecd53e368c16a5f75967a0/Lib/calendar.py#L44-L54
@tomasr8 thanks, I've been looking at this exact file as a reference! Can you confirm which of the tasks are already done? For example in _abc.py, in the load_module() function I can already see a "# Warning implemented in _load_module_shim()." message.
Hi @brettcannon, I'm sitting at Europython sprints and working with @rashansmith. If you know if any of these have already been done, please let us know. Going to check the history :D
GH-121765 is a backport of this pull request to the 3.14 branch.
@brettcannon @willingc @tomasr8 I've created a PR for this issue. Please let me know if it looks good or any issues I should resolve. It is based on validating which deprecationwarnings have already been implemented from the list, and therefore working on the remainders:
- importlib.abc.Loader
- importlib.abc.InspectLoader.load_module() - already done
- importlib.abc.FileLoader.load_module() - already done
- importlib.abc.SourceLoader.load_module() - already done
- importlib.machinery.SourceFileLoader.load_module() - already done
- imortlib.machinery.SourcelessFileLoader - PR
- importlib.abc.ResourceLoader PR
- importlib.abc.SourceLoader.path_mtime() PR
- importlib.machinery.DEBUG_BYTECODE_SUFFIXES PR
- importlib.machinery.OPTIMIZED_BYTECODE_SUFFIXES PR
- importlib.machinery.WindowsRegistryFinder PR
- debug_override parameter of importlib.util.cache_from_source() - already done
@willingc @rashansmith I made the list from the docs based on a comment on another issue that made it sound like SourceFileLoader.load_module() wasn't raising an exception. I had not taken the time to verify anything. So thanks to @rashansmith for checking! I'll update the list based on what you found.
Do we have it documented somewhere that importlib.abc.Loader is deprecated? The current importlib docs only say that importlib.abc.Loader.load_module is deprecated.
I don't think it is. At least there are no deprecation warnings in the code, just for load_module.
That's what I thought, but I was thinking maybe I missed something given the warnings that the linked MR is adding. I'll bring the conversation over there.
All of the items mentioned in the issue now raise warnings, I think we can close this issue?
@brettcannon Since you opened the original issue, do you want to close this as completed? Thanks!
Thanks to everyone who worked on this (especially @tomasr8 for pushing it over the finish line)!