From da75222fa286588394da7f689d47bd53716ffaa1 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 9 May 2009 10:25:32 -0400 Subject: Simplify the construction of the __main__ module in run_python_file. --- coverage/execfile.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'coverage/execfile.py') diff --git a/coverage/execfile.py b/coverage/execfile.py index e066e205..e7d2c774 100644 --- a/coverage/execfile.py +++ b/coverage/execfile.py @@ -12,13 +12,10 @@ def run_python_file(filename, args): """ # Create a module to serve as __main__ old_main_mod = sys.modules['__main__'] - main_mod = imp.new_module("__main__") + main_mod = imp.new_module('__main__') sys.modules['__main__'] = main_mod - main_mod.__dict__.update({ - '__name__': '__main__', - '__file__': filename, - }) - + main_mod.__file__ = filename + # Set sys.argv and the first path element properly. old_argv = sys.argv old_path0 = sys.path[0] -- cgit v1.2.1