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.
--- 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