mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
bpo-26131: Deprecate usage of load_module() (GH-23469)
Raise an ImportWarning when the import system falls back on load_module(). As for implementations of load_module(), raise a DeprecationWarning.
This commit is contained in:
parent
79c1849b9e
commit
2de5097ba4
25 changed files with 3245 additions and 3034 deletions
|
@ -22,6 +22,7 @@ import _io # for open
|
|||
import marshal # for loads
|
||||
import sys # for modules
|
||||
import time # for mktime
|
||||
import _warnings # For warn()
|
||||
|
||||
__all__ = ['ZipImportError', 'zipimporter']
|
||||
|
||||
|
@ -268,8 +269,11 @@ class zipimporter(_bootstrap_external._LoaderBasics):
|
|||
fully qualified (dotted) module name. It returns the imported
|
||||
module, or raises ZipImportError if it wasn't found.
|
||||
|
||||
Deprecated since Python 3.10. use exec_module() instead.
|
||||
Deprecated since Python 3.10. Use exec_module() instead.
|
||||
"""
|
||||
msg = ("zipimport.zipimporter.load_module() is deprecated and slated for "
|
||||
"removal in Python 3.12; use exec_module() instead")
|
||||
_warnings.warn(msg, DeprecationWarning)
|
||||
code, ispackage, modpath = _get_module_code(self, fullname)
|
||||
mod = sys.modules.get(fullname)
|
||||
if mod is None or not isinstance(mod, _module_type):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue