# HG changeset patch # User Brendan Cully # Date 1166242580 28800 # Node ID f9136599700f6c66a0fff654fa93442b4dc9fb12 # Parent 0d27502a804ccb0257a58bac73758edb95d19be5 Make demandimport pass all tests on python2.5. diff --git a/mercurial/demandimport.py b/mercurial/demandimport.py --- a/mercurial/demandimport.py +++ b/mercurial/demandimport.py @@ -59,7 +59,9 @@ class _demandmod(object): return "" % 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 @@ def _demandimport(name, globals=None, lo # 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 @@ def _demandimport(name, globals=None, lo setattr(mod, x, _demandmod(x, mod.__dict__, mod.__dict__)) return mod -ignore = ['_hashlib', 'email.mime'] +ignore = [] def enable(): "enable global demand-loading of modules"