##// 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 return "<unloaded module '%s'>" % self._data[0]
59 return "<unloaded module '%s'>" % self._data[0]
60 def __call__(self, *args, **kwargs):
60 def __call__(self, *args, **kwargs):
61 raise TypeError("'unloaded module' object is not callable")
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 self._load()
65 self._load()
64 return getattr(self._module, attr)
66 return getattr(self._module, attr)
65 def __setattr__(self, attr, val):
67 def __setattr__(self, attr, val):
@@ -74,6 +76,9 b' def _demandimport(name, globals=None, lo'
74 # import a [as b]
76 # import a [as b]
75 if '.' in name: # a.b
77 if '.' in name: # a.b
76 base, rest = name.split('.', 1)
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 # if a is already demand-loaded, add b to its submodule list
82 # if a is already demand-loaded, add b to its submodule list
78 if base in locals:
83 if base in locals:
79 if isinstance(locals[base], _demandmod):
84 if isinstance(locals[base], _demandmod):
@@ -92,7 +97,7 b' def _demandimport(name, globals=None, lo'
92 setattr(mod, x, _demandmod(x, mod.__dict__, mod.__dict__))
97 setattr(mod, x, _demandmod(x, mod.__dict__, mod.__dict__))
93 return mod
98 return mod
94
99
95 ignore = ['_hashlib', 'email.mime']
100 ignore = []
96
101
97 def enable():
102 def enable():
98 "enable global demand-loading of modules"
103 "enable global demand-loading of modules"
General Comments 0
You need to be logged in to leave comments. Login now