##// END OF EJS Templates
Make demandimport pass all tests on python2.5.
Brendan Cully -
r3903:f9136599 default
parent child Browse files
Show More
@@ -59,7 +59,9 b' class _demandmod(object):'
59 59 return "<unloaded module '%s'>" % self._data[0]
60 60 def __call__(self, *args, **kwargs):
61 61 raise TypeError("'unloaded module' object is not callable")
62 def __getattr__(self, attr):
62 def __getattribute__(self, attr):
63 if attr in ('_data', '_extend', '_load', '_module'):
64 return object.__getattribute__(self, attr)
63 65 self._load()
64 66 return getattr(self._module, attr)
65 67 def __setattr__(self, attr, val):
@@ -74,6 +76,9 b' def _demandimport(name, globals=None, lo'
74 76 # import a [as b]
75 77 if '.' in name: # a.b
76 78 base, rest = name.split('.', 1)
79 # email.__init__ loading email.mime
80 if globals and globals.get('__name__', None) == base:
81 return _origimport(name, globals, locals, fromlist)
77 82 # if a is already demand-loaded, add b to its submodule list
78 83 if base in locals:
79 84 if isinstance(locals[base], _demandmod):
@@ -92,7 +97,7 b' def _demandimport(name, globals=None, lo'
92 97 setattr(mod, x, _demandmod(x, mod.__dict__, mod.__dict__))
93 98 return mod
94 99
95 ignore = ['_hashlib', 'email.mime']
100 ignore = []
96 101
97 102 def enable():
98 103 "enable global demand-loading of modules"
General Comments 0
You need to be logged in to leave comments. Login now