summaryrefslogtreecommitdiff
path: root/coverage/execfile.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2011-10-30 22:31:27 -0400
committerNed Batchelder <ned@nedbatchelder.com>2011-10-30 22:31:27 -0400
commit8f059350fda7801522e38e34c1e5851d2975fc7f (patch)
tree612e4762757a8e8b96526c3f83ec8e2b63bf586e /coverage/execfile.py
parentaa04705df95b2033376f6dab8bfcf83aa6293926 (diff)
downloadpython-coveragepy-8f059350fda7801522e38e34c1e5851d2975fc7f.tar.gz
Make execution with -m match Python more closely.
Diffstat (limited to 'coverage/execfile.py')
-rw-r--r--coverage/execfile.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/coverage/execfile.py b/coverage/execfile.py
index 71227b7..1c0048f 100644
--- a/coverage/execfile.py
+++ b/coverage/execfile.py
@@ -65,6 +65,7 @@ def run_python_module(modulename, args):
openfile.close()
# Finally, hand the file off to run_python_file for execution.
+ args[0] = pathname
run_python_file(pathname, args, package=packagename)
@@ -89,7 +90,10 @@ def run_python_file(filename, args, package=None):
old_argv = sys.argv
old_path0 = sys.path[0]
sys.argv = args
- sys.path[0] = os.path.abspath(os.path.dirname(filename))
+ if package:
+ sys.path[0] = ''
+ else:
+ sys.path[0] = os.path.abspath(os.path.dirname(filename))
try:
# Open the source file.