core: add a nasty hack for Ansible modules.

wip-fakessh-exit-status
David Wilson 7 years ago
parent 875ee29d4f
commit 020036f807

@ -546,7 +546,13 @@ class Importer(object):
self._present[fullname] = pkg_present
else:
mod.__package__ = fullname.rpartition('.')[0] or None
code = compile(self.get_source(fullname), mod.__file__, 'exec')
# TODO: monster hack: work around modules now being imported as their
# actual name, so when Ansible "apt.py" tries to "import apt", it gets
# itself. Instead force absolute imports during compilation.
flags = 0x4000 if fullname.startswith('ansible') else 0
source = self.get_source(fullname)
code = compile(source, mod.__file__, 'exec', flags, True)
exec code in vars(mod)
return mod

Loading…
Cancel
Save