diff mercurial/demandimport.py @ 4631:e3afa670e484

demandimport: fix issue579 and add a test fix suggested by Brendan
author Matt Mackall <mpm@selenic.com>
date Mon, 18 Jun 2007 19:43:26 -0500
parents eb99af2d845e
children 63b9d2deed48
line wrap: on
line diff
--- a/mercurial/demandimport.py
+++ b/mercurial/demandimport.py
@@ -61,7 +61,10 @@ class _demandmod(object):
             if locals and locals.get(head) == self:
                 locals[head] = mod
             object.__setattr__(self, "_module", mod)
+
     def __repr__(self):
+        if self._module:
+            return "<proxied module '%s'>" % self._data[0]
         return "<unloaded module '%s'>" % self._data[0]
     def __call__(self, *args, **kwargs):
         raise TypeError("'unloaded module' object is not callable")
@@ -102,7 +105,7 @@ def _demandimport(name, globals=None, lo
         for x in fromlist:
             # set requested submodules for demand load
             if not(hasattr(mod, x)):
-                setattr(mod, x, _demandmod(x, mod.__dict__, mod.__dict__))
+                setattr(mod, x, _demandmod(x, mod.__dict__, locals))
         return mod
 
 ignore = ['_hashlib', '_xmlplus', 'fcntl', 'win32com.gen_py']