diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-05-09 10:25:32 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-05-09 10:25:32 -0400 |
commit | bd0921599e5c93271806fb7699f1e786c8dad6ac (patch) | |
tree | 9e4a47aefd0062e96cc5392b9d03da40c589272d /coverage/execfile.py | |
parent | 6425cd30f957b28f72e9bab10a9aec087089ba3f (diff) | |
download | python-coveragepy-bd0921599e5c93271806fb7699f1e786c8dad6ac.tar.gz |
Simplify the construction of the __main__ module in run_python_file.
Diffstat (limited to 'coverage/execfile.py')
-rw-r--r-- | coverage/execfile.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/coverage/execfile.py b/coverage/execfile.py index e066e20..e7d2c77 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] |