diff --git a/ansible_mitogen/runner.py b/ansible_mitogen/runner.py index af3e2bf7..5b58116b 100644 --- a/ansible_mitogen/runner.py +++ b/ansible_mitogen/runner.py @@ -386,6 +386,8 @@ class NewStyleRunner(ScriptRunner): def _run(self): code = self._get_code() mod = types.ModuleType('__main__') + mod.__file__ = self.program_fp.name + mod.__package__ = None d = vars(mod) e = None diff --git a/tests/ansible/lib/modules/custom_python_new_style_module.py b/tests/ansible/lib/modules/custom_python_new_style_module.py index 1ae50d50..4bc9794d 100755 --- a/tests/ansible/lib/modules/custom_python_new_style_module.py +++ b/tests/ansible/lib/modules/custom_python_new_style_module.py @@ -21,6 +21,11 @@ input_json = sys.stdin.read() print "{" print " \"changed\": false," +# v2.5.1. apt.py started depending on this. +# https://github.com/dw/mitogen/issues/210 +print " \"__file__\": \"%s\"," % (__file__,) +# Python sets this during a regular import. +print " \"__package__\": \"%s\"," % (__package__,) print " \"msg\": \"Here is my input\"," print " \"source\": [%s]," % (json.dumps(me),) print " \"input\": [%s]" % (input_json,)