changeset 3903:f9136599700f

Make demandimport pass all tests on python2.5.
author Brendan Cully <brendan@kublai.com>
date Fri, 15 Dec 2006 20:16:20 -0800
parents 0d27502a804c
children 1063a631cb8e
files mercurial/demandimport.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/demandimport.py	Fri Dec 15 18:38:09 2006 -0800
+++ b/mercurial/demandimport.py	Fri Dec 15 20:16:20 2006 -0800
@@ -59,7 +59,9 @@
         return "<unloaded module '%s'>" % self._data[0]
     def __call__(self, *args, **kwargs):
         raise TypeError("'unloaded module' object is not callable")
-    def __getattr__(self, attr):
+    def __getattribute__(self, attr):
+        if attr in ('_data', '_extend', '_load', '_module'):
+            return object.__getattribute__(self, attr)
         self._load()
         return getattr(self._module, attr)
     def __setattr__(self, attr, val):
@@ -74,6 +76,9 @@
         # import a [as b]
         if '.' in name: # a.b
             base, rest = name.split('.', 1)
+            # email.__init__ loading email.mime
+            if globals and globals.get('__name__', None) == base:
+                return _origimport(name, globals, locals, fromlist)
             # if a is already demand-loaded, add b to its submodule list
             if base in locals:
                 if isinstance(locals[base], _demandmod):
@@ -92,7 +97,7 @@
                 setattr(mod, x, _demandmod(x, mod.__dict__, mod.__dict__))
         return mod
 
-ignore = ['_hashlib', 'email.mime']
+ignore = []
 
 def enable():
     "enable global demand-loading of modules"