changeset 5929:e160f2312815

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.
author Ali Gholami Rudi <aligrudi@users.sourceforge.net>
date Wed, 16 Jan 2008 19:14:54 +0330
parents 3340aa5a64f7
children c301f15c965a
files mercurial/demandimport.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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