diff --git a/mitogen/core.py b/mitogen/core.py index 2e1ad8aa..b2b7e0df 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -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