From 975b325978366fe9b3ddac793d15c21567cf0e11 Mon Sep 17 00:00:00 2001 From: Wulian Date: Mon, 21 Oct 2024 19:43:30 +0800 Subject: [PATCH 1/5] Delay deprecated --- Doc/deprecations/pending-removal-in-3.15.rst | 5 +++++ Doc/deprecations/pending-removal-in-future.rst | 3 --- Lib/zipimport.py | 2 +- .../Library/2024-10-20-13-01-05.gh-issue-125746.wDLTay.rst | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2024-10-20-13-01-05.gh-issue-125746.wDLTay.rst diff --git a/Doc/deprecations/pending-removal-in-3.15.rst b/Doc/deprecations/pending-removal-in-3.15.rst index 17029b8d4773bd..e20510a751f708 100644 --- a/Doc/deprecations/pending-removal-in-3.15.rst +++ b/Doc/deprecations/pending-removal-in-3.15.rst @@ -78,3 +78,8 @@ Pending removal in Python 3.15 and :meth:`~wave.Wave_read.getmarkers` methods of the :class:`~wave.Wave_read` and :class:`~wave.Wave_write` classes have been deprecated since Python 3.13. + +* :mod:`zipimport`: + +* :meth:`~zipimport.zipimporter.load_module` have been deprecated since + Python 3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead. diff --git a/Doc/deprecations/pending-removal-in-future.rst b/Doc/deprecations/pending-removal-in-future.rst index d77fc86eab0ed6..6cb673325f2491 100644 --- a/Doc/deprecations/pending-removal-in-future.rst +++ b/Doc/deprecations/pending-removal-in-future.rst @@ -155,6 +155,3 @@ although there is currently no date scheduled for their removal. :class:`~xml.etree.ElementTree.Element` is deprecated. In a future release it will always return ``True``. Prefer explicit ``len(elem)`` or ``elem is not None`` tests instead. - -* :meth:`zipimport.zipimporter.load_module` is deprecated: - use :meth:`~zipimport.zipimporter.exec_module` instead. diff --git a/Lib/zipimport.py b/Lib/zipimport.py index e5192c4d074c4b..d9ce8ef075f311 100644 --- a/Lib/zipimport.py +++ b/Lib/zipimport.py @@ -222,7 +222,7 @@ def load_module(self, fullname): 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") + "removal in Python 3.15; use exec_module() instead") _warnings.warn(msg, DeprecationWarning) code, ispackage, modpath = _get_module_code(self, fullname) mod = sys.modules.get(fullname) diff --git a/Misc/NEWS.d/next/Library/2024-10-20-13-01-05.gh-issue-125746.wDLTay.rst b/Misc/NEWS.d/next/Library/2024-10-20-13-01-05.gh-issue-125746.wDLTay.rst new file mode 100644 index 00000000000000..e22f018ce86a32 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-10-20-13-01-05.gh-issue-125746.wDLTay.rst @@ -0,0 +1,2 @@ +Delay deprecated :meth:`~zipimport.zipimporter.load_module` removal +time to 3.15. Use :meth:`~zipimport.zipimporter.exec_module` instead. From dd4d06e5a86b3e5f963b969a8d860d2bb0602a7b Mon Sep 17 00:00:00 2001 From: Wulian <1055917385@qq.com> Date: Tue, 22 Oct 2024 06:41:07 +0800 Subject: [PATCH 2/5] warnings --- Lib/zipimport.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Lib/zipimport.py b/Lib/zipimport.py index d9ce8ef075f311..2745c47d34abd0 100644 --- a/Lib/zipimport.py +++ b/Lib/zipimport.py @@ -20,7 +20,7 @@ import marshal # for loads import sys # for modules import time # for mktime -import _warnings # For warn() +import warnings # For warnings __all__ = ['ZipImportError', 'zipimporter'] @@ -221,9 +221,10 @@ def load_module(self, fullname): Deprecated since Python 3.10. Use exec_module() instead. """ - msg = ("zipimport.zipimporter.load_module() is deprecated and slated for " - "removal in Python 3.15; use exec_module() instead") - _warnings.warn(msg, DeprecationWarning) + warnings._deprecated("zipimport.zipimporter.load_module", + f"{warnings._DEPRECATED_MSG}; " + "use zipimport.zipimporter.exec_module() instead", + remove=(3, 15)) code, ispackage, modpath = _get_module_code(self, fullname) mod = sys.modules.get(fullname) if mod is None or not isinstance(mod, _module_type): From f7bea5d04c941a2aacd13a7da11c353c9dbba683 Mon Sep 17 00:00:00 2001 From: Wulian <1055917385@qq.com> Date: Tue, 22 Oct 2024 06:52:13 +0800 Subject: [PATCH 3/5] typo --- Lib/zipimport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/zipimport.py b/Lib/zipimport.py index 2745c47d34abd0..d83bc295ab2590 100644 --- a/Lib/zipimport.py +++ b/Lib/zipimport.py @@ -221,7 +221,7 @@ def load_module(self, fullname): Deprecated since Python 3.10. Use exec_module() instead. """ - warnings._deprecated("zipimport.zipimporter.load_module", + warnings._deprecated("zipimport.zipimporter.load_module", f"{warnings._DEPRECATED_MSG}; " "use zipimport.zipimporter.exec_module() instead", remove=(3, 15)) From cfd1976a819ee6570de4f9176869f3d49b305f8a Mon Sep 17 00:00:00 2001 From: Wulian <1055917385@qq.com> Date: Wed, 23 Oct 2024 06:26:06 +0800 Subject: [PATCH 4/5] Update Doc/deprecations/pending-removal-in-3.15.rst Co-authored-by: Brett Cannon --- Doc/deprecations/pending-removal-in-3.15.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/deprecations/pending-removal-in-3.15.rst b/Doc/deprecations/pending-removal-in-3.15.rst index e20510a751f708..bada7880b4efd9 100644 --- a/Doc/deprecations/pending-removal-in-3.15.rst +++ b/Doc/deprecations/pending-removal-in-3.15.rst @@ -81,5 +81,5 @@ Pending removal in Python 3.15 * :mod:`zipimport`: -* :meth:`~zipimport.zipimporter.load_module` have been deprecated since +* :meth:`~zipimport.zipimporter.load_module` has been deprecated since Python 3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead. From 7c36afa35061b722100b92d600c3a1f7f003aa9f Mon Sep 17 00:00:00 2001 From: Wulian Date: Mon, 11 Nov 2024 19:33:35 +0800 Subject: [PATCH 5/5] Apply picnixz suggesions --- Doc/deprecations/pending-removal-in-3.15.rst | 5 +++-- Doc/library/zipimport.rst | 2 +- Lib/zipimport.py | 8 ++++---- .../2024-10-20-13-01-05.gh-issue-125746.wDLTay.rst | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Doc/deprecations/pending-removal-in-3.15.rst b/Doc/deprecations/pending-removal-in-3.15.rst index bada7880b4efd9..e53c9f9788733b 100644 --- a/Doc/deprecations/pending-removal-in-3.15.rst +++ b/Doc/deprecations/pending-removal-in-3.15.rst @@ -81,5 +81,6 @@ Pending removal in Python 3.15 * :mod:`zipimport`: -* :meth:`~zipimport.zipimporter.load_module` has been deprecated since - Python 3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead. + * :meth:`~zipimport.zipimporter.load_module` has been deprecated since + Python 3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead. + (Contributed by Jiahao Li in :gh:`125746`.) diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst index 9353a45bdcecba..cd76f29a556939 100644 --- a/Doc/library/zipimport.rst +++ b/Doc/library/zipimport.rst @@ -148,7 +148,7 @@ zipimporter Objects qualified (dotted) module name. Returns the imported module on success, raises :exc:`ZipImportError` on failure. - .. deprecated:: 3.10 + .. deprecated-removed:: 3.10 3.15 Use :meth:`exec_module` instead. diff --git a/Lib/zipimport.py b/Lib/zipimport.py index d83bc295ab2590..444c9dd11d8672 100644 --- a/Lib/zipimport.py +++ b/Lib/zipimport.py @@ -20,7 +20,6 @@ import marshal # for loads import sys # for modules import time # for mktime -import warnings # For warnings __all__ = ['ZipImportError', 'zipimporter'] @@ -221,10 +220,11 @@ def load_module(self, fullname): Deprecated since Python 3.10. Use exec_module() instead. """ + import warnings warnings._deprecated("zipimport.zipimporter.load_module", - f"{warnings._DEPRECATED_MSG}; " - "use zipimport.zipimporter.exec_module() instead", - remove=(3, 15)) + f"{warnings._DEPRECATED_MSG}; " + "use zipimport.zipimporter.exec_module() instead", + remove=(3, 15)) code, ispackage, modpath = _get_module_code(self, fullname) mod = sys.modules.get(fullname) if mod is None or not isinstance(mod, _module_type): diff --git a/Misc/NEWS.d/next/Library/2024-10-20-13-01-05.gh-issue-125746.wDLTay.rst b/Misc/NEWS.d/next/Library/2024-10-20-13-01-05.gh-issue-125746.wDLTay.rst index e22f018ce86a32..387d793fd209d9 100644 --- a/Misc/NEWS.d/next/Library/2024-10-20-13-01-05.gh-issue-125746.wDLTay.rst +++ b/Misc/NEWS.d/next/Library/2024-10-20-13-01-05.gh-issue-125746.wDLTay.rst @@ -1,2 +1,2 @@ -Delay deprecated :meth:`~zipimport.zipimporter.load_module` removal -time to 3.15. Use :meth:`~zipimport.zipimporter.exec_module` instead. +Delay deprecated :meth:`zipimport.zipimporter.load_module` removal +time to 3.15. Use :meth:`zipimport.zipimporter.exec_module` instead.