demandimport: handling new relative imports
authorAli Gholami Rudi <aligrudi@users.sourceforge.net>
Wed, 16 Jan 2008 19:14:54 +0330
changeset 5929 e160f2312815
parent 5928 3340aa5a64f7
child 5930 c301f15c965a
demandimport: handling new relative imports Mercurial does not work on python2.6 because __import__ takes an additional argument called level. This patch merely calls the built-in __import__ when level is passed.
mercurial/demandimport.py
--- a/mercurial/demandimport.py	Tue Jan 22 10:45:55 2008 +0100
+++ b/mercurial/demandimport.py	Wed Jan 16 19:14:54 2008 +0330
@@ -77,7 +77,7 @@
         self._load()
         setattr(self._module, attr, val)
 
-def _demandimport(name, globals=None, locals=None, fromlist=None):
+def _demandimport(name, globals=None, locals=None, fromlist=None, level=None):
     if not locals or name in ignore or fromlist == ('*',):
         # these cases we can't really delay
         return _origimport(name, globals, locals, fromlist)
@@ -95,6 +95,9 @@
                 return locals[base]
         return _demandmod(name, globals, locals)
     else:
+        if level is not None:
+            # from . import b,c,d or from .a import b,c,d
+            return _origimport(name, globals, locals, fromlist, level)
         # from a import b,c,d
         mod = _origimport(name, globals, locals)
         # recurse down the module chain