demandimport: patch __builtin__ instead of __builtins__
authorDirkjan Ochtman <dirkjan@ochtman.nl>
Thu, 05 Feb 2009 17:40:25 +0100
changeset 7727 25fc4c620e54
parent 7726 2486980fe211
child 7728 b7ac53f7b061
child 7735 2e48668b51f0
demandimport: patch __builtin__ instead of __builtins__ This helps on implementations other than CPython, where __builtins__ isn't necessarily defined (as it's an implementation detail for CPython).
mercurial/demandimport.py
--- a/mercurial/demandimport.py	Thu Feb 05 18:21:22 2009 +0100
+++ b/mercurial/demandimport.py	Thu Feb 05 17:40:25 2009 +0100
@@ -24,6 +24,7 @@
   b = __import__(a)
 '''
 
+import __builtin__
 _origimport = __import__
 
 class _demandmod(object):
@@ -126,9 +127,9 @@
 
 def enable():
     "enable global demand-loading of modules"
-    __builtins__["__import__"] = _demandimport
+    __builtin__.__import__ = _demandimport
 
 def disable():
     "disable global demand-loading of modules"
-    __builtins__["__import__"] = _origimport
+    __builtin__.__import__ = _origimport