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).
--- 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