Ensure mod.__file__ is set; closes #210.

pull/211/head
David Wilson 7 years ago
parent b2abe74ab6
commit 86c9978e09

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

@ -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,)

Loading…
Cancel
Save