summaryrefslogtreecommitdiffstats
path: root/Lib/zipimport.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2020-12-04 23:39:21 (GMT)
committerGitHub <noreply@github.com>2020-12-04 23:39:21 (GMT)
commit2de5097ba4c50eba90df55696a7b2e74c93834d4 (patch)
tree7a3d54477997114ef27136e9c9da0e380f835a34 /Lib/zipimport.py
parent79c1849b9e5b635bd36b13e1be9dc7cbc2bd6312 (diff)
downloadcpython-2de5097ba4c50eba90df55696a7b2e74c93834d4.zip
cpython-2de5097ba4c50eba90df55696a7b2e74c93834d4.tar.gz
cpython-2de5097ba4c50eba90df55696a7b2e74c93834d4.tar.bz2
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.
Diffstat (limited to 'Lib/zipimport.py')
-rw-r--r--Lib/zipimport.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/zipimport.py b/Lib/zipimport.py
index 2e5188a..02e4fd3 100644
--- a/Lib/zipimport.py
+++ b/Lib/zipimport.py
@@ -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):