summaryrefslogtreecommitdiff
path: root/coverage/execfile.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-09-22 07:22:56 -0400
committerNed Batchelder <ned@nedbatchelder.com>2009-09-22 07:22:56 -0400
commitff9099051e0daff7b08035713eeca5696ab3217a (patch)
tree13a391e9010e9e0b99ff403ec2fd0252d460ab5a /coverage/execfile.py
parente3c0b4b2c7d2a92344d30a25467a1e863bbb7d31 (diff)
downloadpython-coveragepy-git-ff9099051e0daff7b08035713eeca5696ab3217a.tar.gz
The best way to get py3k support: same source runs on both, with some contortions.
Diffstat (limited to 'coverage/execfile.py')
-rw-r--r--coverage/execfile.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/coverage/execfile.py b/coverage/execfile.py
index a345c767..cf8e1ec2 100644
--- a/coverage/execfile.py
+++ b/coverage/execfile.py
@@ -2,6 +2,9 @@
import imp, os, sys
+from coverage.backward import exec_function
+
+
try:
# In Py 2.x, the builtins were in __builtin__
BUILTINS = sys.modules['__builtin__']
@@ -33,7 +36,7 @@ def run_python_file(filename, args):
try:
source = open(filename, 'rU').read()
- exec compile(source, filename, "exec") in main_mod.__dict__
+ exec_function(source, filename, main_mod.__dict__)
finally:
# Restore the old __main__
sys.modules['__main__'] = old_main_mod