mirror of
https://github.com/python/cpython.git
synced 2025-10-27 08:46:53 +00:00
Add a reset_name argument to importlib.util.module_to_load in order to
control whether to reset the module's __name__ attribute in case a reload is being done.
This commit is contained in:
parent
028d51236a
commit
b60a43eabf
3 changed files with 30 additions and 2 deletions
|
|
@ -788,7 +788,7 @@ an :term:`importer`.
|
|||
|
||||
.. versionadded:: 3.3
|
||||
|
||||
.. function:: module_to_load(name)
|
||||
.. function:: module_to_load(name, *, reset_name=True)
|
||||
|
||||
Returns a :term:`context manager` which provides the module to load. The
|
||||
module will either come from :attr:`sys.modules` in the case of reloading or
|
||||
|
|
@ -796,6 +796,10 @@ an :term:`importer`.
|
|||
:attr:`sys.modules` occurs if the module was new and an exception was
|
||||
raised.
|
||||
|
||||
If **reset_name** is true and the module requested is being reloaded then
|
||||
the module's :attr:`__name__` attribute will
|
||||
be reset to **name**, else it will be left untouched.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
|
||||
.. decorator:: module_for_loader
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue