[Bug 4029] New: demandimport doesn't honor absolute_import
mercurial-bugs at selenic.com
mercurial-bugs at selenic.com
Thu Sep 5 21:22:54 CDT 2013
http://bz.selenic.com/show_bug.cgi?id=4029
Priority: normal
Bug ID: 4029
CC: mercurial-devel at selenic.com
Assignee: bugzilla at selenic.com
Summary: demandimport doesn't honor absolute_import
Severity: bug
Classification: Unclassified
OS: Windows
Reporter: jaraco at jaraco.com
Hardware: PC
Status: UNCONFIRMED
Version: 2.7.1
Component: Mercurial
Product: Mercurial
In
https://bitbucket.org/Mekk/mercurial_keyring/issue/31/failed-to-import-extension,
it became apparent that the demand import machinery doesn't honor the
'absolute_import' directive. If a relative import is present, it is given
preference even if the module author has indicated absolute_import from
__future__.
I believe the fix is pretty straightforward. I've tested this against the
reported issue and it fixes the failure (and imports the correct module from
the root namespace).
Please consider committing this patch. Thanks.
diff -r 1d07bf106c2a mercurial/demandimport.py
--- a/mercurial/demandimport.py Wed Sep 04 18:42:55 2013 -0700
+++ b/mercurial/demandimport.py Thu Sep 05 22:11:20 2013 -0400
@@ -55,7 +55,9 @@
def _load(self):
if not self._module:
head, globals, locals, after = self._data
- mod = _origimport(head, globals, locals)
+ if 'absolute_import' in locals:
+ level = 0
+ mod = _origimport(head, globals, locals, [], level)
# load submodules
def subload(mod, p):
h, t = p, None
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Mercurial-devel
mailing list