Skip to content

Commit 06ac157

Browse files
authored
gh-125746: Delay deprecated zipimport.zipimporter.load_module removal time to 3.15 (#125748)
1 parent a7427f2 commit 06ac157

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

Doc/deprecations/pending-removal-in-3.15.rst

+6
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,9 @@ Pending removal in Python 3.15
9696
and :meth:`~wave.Wave_read.getmarkers` methods of
9797
the :class:`~wave.Wave_read` and :class:`~wave.Wave_write` classes
9898
have been deprecated since Python 3.13.
99+
100+
* :mod:`zipimport`:
101+
102+
* :meth:`~zipimport.zipimporter.load_module` has been deprecated since
103+
Python 3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead.
104+
(Contributed by Jiahao Li in :gh:`125746`.)

Doc/deprecations/pending-removal-in-future.rst

-3
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,3 @@ although there is currently no date scheduled for their removal.
151151
:class:`~xml.etree.ElementTree.Element` is deprecated. In a future release it
152152
will always return ``True``. Prefer explicit ``len(elem)`` or
153153
``elem is not None`` tests instead.
154-
155-
* :meth:`zipimport.zipimporter.load_module` is deprecated:
156-
use :meth:`~zipimport.zipimporter.exec_module` instead.

Doc/library/zipimport.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ zipimporter Objects
148148
qualified (dotted) module name. Returns the imported module on success,
149149
raises :exc:`ZipImportError` on failure.
150150

151-
.. deprecated:: 3.10
151+
.. deprecated-removed:: 3.10 3.15
152152

153153
Use :meth:`exec_module` instead.
154154

Lib/zipimport.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import marshal # for loads
2121
import sys # for modules
2222
import time # for mktime
23-
import _warnings # For warn()
2423

2524
__all__ = ['ZipImportError', 'zipimporter']
2625

@@ -221,9 +220,11 @@ def load_module(self, fullname):
221220
222221
Deprecated since Python 3.10. Use exec_module() instead.
223222
"""
224-
msg = ("zipimport.zipimporter.load_module() is deprecated and slated for "
225-
"removal in Python 3.12; use exec_module() instead")
226-
_warnings.warn(msg, DeprecationWarning)
223+
import warnings
224+
warnings._deprecated("zipimport.zipimporter.load_module",
225+
f"{warnings._DEPRECATED_MSG}; "
226+
"use zipimport.zipimporter.exec_module() instead",
227+
remove=(3, 15))
227228
code, ispackage, modpath = _get_module_code(self, fullname)
228229
mod = sys.modules.get(fullname)
229230
if mod is None or not isinstance(mod, _module_type):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Delay deprecated :meth:`zipimport.zipimporter.load_module` removal
2+
time to 3.15. Use :meth:`zipimport.zipimporter.exec_module` instead.

0 commit comments

Comments
 (0)