Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eae3079

Browse files
committed
Issue #25802: Deprecate load_module() on importlib.machinery.SourceFileLoader and SourcelessFileLoader.
They were the only remaining implementations of load_module() not documented as deprecated.
1 parent 53d1f24 commit eae3079

5 files changed

Lines changed: 1535 additions & 1517 deletions

File tree

Doc/library/importlib.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,10 @@ find and load modules.
921921
Concrete implementation of :meth:`importlib.abc.Loader.load_module` where
922922
specifying the name of the module to load is optional.
923923

924+
.. deprecated:: 3.6
925+
926+
Use :meth:`importlib.abc.Loader.exec_module` instead.
927+
924928

925929
.. class:: SourcelessFileLoader(fullname, path)
926930

@@ -960,6 +964,10 @@ find and load modules.
960964
Concrete implementation of :meth:`importlib.abc.Loader.load_module` where
961965
specifying the name of the module to load is optional.
962966

967+
.. deprecated:: 3.6
968+
969+
Use :meth:`importlib.abc.Loader.exec_module` instead.
970+
963971

964972
.. class:: ExtensionFileLoader(fullname, path)
965973

Doc/whatsnew/3.6.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,12 @@ become proper keywords in Python 3.7.
189189
Deprecated Python modules, functions and methods
190190
------------------------------------------------
191191

192-
* None yet.
192+
* :meth:`importlib.machinery.SourceFileLoader` and
193+
:meth:`importlib.machinery.SourcelessFileLoader` are now deprecated. They
194+
were the only remaining implementations of
195+
:meth:`importlib.abc.Loader.load_module` in :mod:`importlib` that had not
196+
been deprecated in previous versions of Python in favour of
197+
:meth:`importlib.abc.Loader.exec_module`.
193198

194199

195200
Deprecated functions and types of the C API

Lib/importlib/_bootstrap_external.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ def exec_module(self, module):
655655
_bootstrap._call_with_frames_removed(exec, code, module.__dict__)
656656

657657
def load_module(self, fullname):
658+
"""This module is deprecated."""
658659
return _bootstrap._load_module_shim(self, fullname)
659660

660661

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ Core and Builtins
123123
Library
124124
-------
125125

126+
- Issue #25802: Document as deprecated the remaining implementations of
127+
importlib.abc.Loader.load_module().
128+
126129
- Issue #25928: Add Decimal.as_integer_ratio().
127130

128131
- Issue #25447: Copying the lru_cache() wrapper object now always works,

0 commit comments

Comments
 (0)