@@ -210,6 +210,12 @@ Functions
210210 :exc: `ModuleNotFoundError ` is raised when the module being reloaded lacks
211211 a :class: `~importlib.machinery.ModuleSpec `.
212212
213+ .. versionchanged :: next
214+ If *module * is a lazy module that has not yet been materialized (i.e.,
215+ loaded via :class: `importlib.util.LazyLoader ` and not yet accessed),
216+ calling :func: `reload ` is a no-op and returns the module unchanged.
217+ This prevents the reload from unintentionally triggering the lazy load.
218+
213219 .. warning ::
214220 This function is not thread-safe. Calling it from multiple threads can result
215221 in unexpected behavior. It's recommended to use the :class: `threading.Lock `
@@ -320,6 +326,9 @@ ABC hierarchy::
320326 .. versionchanged :: 3.7
321327 Introduced the optional :meth: `get_resource_reader ` method.
322328
329+ .. versionchanged :: 3.15
330+ Removed the ``load_module() `` method.
331+
323332 .. method :: create_module(spec)
324333
325334 A method that returns the module object to use when
@@ -344,47 +353,6 @@ ABC hierarchy::
344353 .. versionchanged :: 3.6
345354 :meth: `create_module ` must also be defined.
346355
347- .. method :: load_module(fullname)
348-
349- A legacy method for loading a module. If the module cannot be
350- loaded, :exc: `ImportError ` is raised, otherwise the loaded module is
351- returned.
352-
353- If the requested module already exists in :data: `sys.modules `, that
354- module should be used and reloaded.
355- Otherwise the loader should create a new module and insert it into
356- :data: `sys.modules ` before any loading begins, to prevent recursion
357- from the import. If the loader inserted a module and the load fails, it
358- must be removed by the loader from :data: `sys.modules `; modules already
359- in :data: `sys.modules ` before the loader began execution should be left
360- alone.
361-
362- The loader should set several attributes on the module
363- (note that some of these attributes can change when a module is
364- reloaded):
365-
366- - :attr: `module.__name__ `
367- - :attr: `module.__file__ `
368- - :attr: `module.__cached__ ` *(deprecated) *
369- - :attr: `module.__path__ `
370- - :attr: `module.__package__ ` *(deprecated) *
371- - :attr: `module.__loader__ ` *(deprecated) *
372-
373- When :meth: `exec_module ` is available then backwards-compatible
374- functionality is provided.
375-
376- .. versionchanged :: 3.4
377- Raise :exc: `ImportError ` when called instead of
378- :exc: `NotImplementedError `. Functionality provided when
379- :meth: `exec_module ` is available.
380-
381- .. deprecated-removed :: 3.4 3.15
382- The recommended API for loading a module is :meth: `exec_module `
383- (and :meth: `create_module `). Loaders should implement it instead of
384- :meth: `load_module `. The import machinery takes care of all the
385- other responsibilities of :meth: `load_module ` when
386- :meth: `exec_module ` is implemented.
387-
388356
389357.. class :: ResourceLoader
390358
@@ -490,13 +458,6 @@ ABC hierarchy::
490458
491459 .. versionadded :: 3.4
492460
493- .. method :: load_module(fullname)
494-
495- Implementation of :meth: `Loader.load_module `.
496-
497- .. deprecated-removed :: 3.4 3.15
498- use :meth: `exec_module ` instead.
499-
500461
501462.. class :: ExecutionLoader
502463
@@ -530,6 +491,9 @@ ABC hierarchy::
530491
531492 .. versionadded :: 3.3
532493
494+ .. versionchanged :: 3.15
495+ Removed the ``load_module() `` method.
496+
533497 .. attribute :: name
534498
535499 The name of the module the loader can handle.
@@ -538,13 +502,6 @@ ABC hierarchy::
538502
539503 Path to the file of the module.
540504
541- .. method :: load_module(fullname)
542-
543- Calls super's ``load_module() ``.
544-
545- .. deprecated-removed :: 3.4 3.15
546- Use :meth: `Loader.exec_module ` instead.
547-
548505 .. method :: get_filename(fullname)
549506 :abstractmethod:
550507
@@ -576,6 +533,9 @@ ABC hierarchy::
576533 optimization to speed up loading by removing the parsing step of Python's
577534 compiler, and so no bytecode-specific API is exposed.
578535
536+ .. versionchanged :: 3.15
537+ Removed the ``load_module() `` method.
538+
579539 .. method :: path_stats(path)
580540
581541 Optional abstract method which returns a :class: `dict ` containing
@@ -629,13 +589,6 @@ ABC hierarchy::
629589
630590 .. versionadded :: 3.4
631591
632- .. method :: load_module(fullname)
633-
634- Concrete implementation of :meth: `Loader.load_module `.
635-
636- .. deprecated-removed :: 3.4 3.15
637- Use :meth: `exec_module ` instead.
638-
639592 .. method :: get_source(fullname)
640593
641594 Concrete implementation of :meth: `InspectLoader.get_source `.
@@ -1059,6 +1012,9 @@ find and load modules.
10591012
10601013 .. versionadded :: 3.3
10611014
1015+ .. versionchanged :: 3.15
1016+ Removed the ``load_module() `` method.
1017+
10621018 .. attribute :: name
10631019
10641020 The name of the module that this loader will handle.
@@ -1079,15 +1035,6 @@ find and load modules.
10791035
10801036 Concrete implementation of :meth: `importlib.abc.SourceLoader.set_data `.
10811037
1082- .. method :: load_module(name=None)
1083-
1084- Concrete implementation of :meth: `importlib.abc.Loader.load_module ` where
1085- specifying the name of the module to load is optional.
1086-
1087- .. deprecated-removed :: 3.6 3.15
1088-
1089- Use :meth: `importlib.abc.Loader.exec_module ` instead.
1090-
10911038
10921039.. class :: SourcelessFileLoader(fullname, path)
10931040
@@ -1101,6 +1048,9 @@ find and load modules.
11011048
11021049 .. versionadded :: 3.3
11031050
1051+ .. versionchanged :: 3.15
1052+ Removed the ``load_module() `` method.
1053+
11041054 .. attribute :: name
11051055
11061056 The name of the module the loader will handle.
@@ -1122,15 +1072,6 @@ find and load modules.
11221072 Returns ``None `` as bytecode files have no source when this loader is
11231073 used.
11241074
1125- .. method :: load_module(name=None)
1126-
1127- Concrete implementation of :meth: `importlib.abc.Loader.load_module ` where
1128- specifying the name of the module to load is optional.
1129-
1130- .. deprecated-removed :: 3.6 3.15
1131-
1132- Use :meth: `importlib.abc.Loader.exec_module ` instead.
1133-
11341075
11351076.. class :: ExtensionFileLoader(fullname, path)
11361077
@@ -1262,8 +1203,7 @@ find and load modules.
12621203
12631204 .. attribute :: cached
12641205
1265- The filename of a compiled version of the module's code
1266- (see :attr: `module.__cached__ `).
1206+ The filename of a compiled version of the module's code.
12671207 The :term: `finder ` should always set this attribute but it may be ``None ``
12681208 for modules that do not need compiled code stored.
12691209
@@ -1365,7 +1305,7 @@ an :term:`importer`.
13651305
13661306 .. versionadded :: 3.4
13671307
1368- .. function :: cache_from_source(path, debug_override=None, *, optimization=None)
1308+ .. function :: cache_from_source(path, *, optimization=None)
13691309
13701310 Return the :pep: `3147 `/:pep: `488 ` path to the byte-compiled file associated
13711311 with the source *path *. For example, if *path * is ``/foo/bar/baz.py `` the return
@@ -1384,12 +1324,6 @@ an :term:`importer`.
13841324 ``/foo/bar/__pycache__/baz.cpython-32.opt-2.pyc ``. The string representation
13851325 of *optimization * can only be alphanumeric, else :exc: `ValueError ` is raised.
13861326
1387- The *debug_override * parameter is deprecated and can be used to override
1388- the system's value for ``__debug__ ``. A ``True `` value is the equivalent of
1389- setting *optimization * to the empty string. A ``False `` value is the same as
1390- setting *optimization * to ``1 ``. If both *debug_override * an *optimization *
1391- are not ``None `` then :exc: `TypeError ` is raised.
1392-
13931327 .. versionadded :: 3.4
13941328
13951329 .. versionchanged :: 3.5
@@ -1399,6 +1333,9 @@ an :term:`importer`.
13991333 .. versionchanged :: 3.6
14001334 Accepts a :term: `path-like object `.
14011335
1336+ .. versionchanged :: 3.15
1337+ The *debug_override * parameter was removed.
1338+
14021339
14031340.. function :: source_from_cache(path)
14041341
0 commit comments