]> granicus.if.org Git - python/commitdiff
Fix for last commit on adding reset_name to module_to_load
authorBrett Cannon <brett@python.org>
Fri, 31 May 2013 22:37:44 +0000 (18:37 -0400)
committerBrett Cannon <brett@python.org>
Fri, 31 May 2013 22:37:44 +0000 (18:37 -0400)
Lib/importlib/_bootstrap.py

index cd6a2639118cbbf780e59b18a78b96bab6a43e85..d4d2f91c39e51feefeb76f10a4d1d4404e0ee75f 100644 (file)
@@ -529,10 +529,13 @@ class _ModuleManager:
             del sys.modules[self._name]
 
 
-def module_to_load(name):
-    """Return a context manager which provides the module object to load."""
+def module_to_load(name, *, reset_name=True):
+    """Return a context manager which provides the module object to load.
+
+    If reset_name is true, reset the module's __name__ to 'name'.
+    """
     # Hiding _ModuleManager behind a function for better naming.
-    return _ModuleManager(name)
+    return _ModuleManager(name, reset_name=reset_name)
 
 
 def set_package(fxn):