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.
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index 976451c..35336b1 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -788,7 +788,7 @@
.. 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 @@
: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