summaryrefslogtreecommitdiff
path: root/coverage/execfile.py
diff options
context:
space:
mode:
Diffstat (limited to 'coverage/execfile.py')
-rw-r--r--coverage/execfile.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/coverage/execfile.py b/coverage/execfile.py
index 246d79a..ecb0337 100644
--- a/coverage/execfile.py
+++ b/coverage/execfile.py
@@ -8,7 +8,7 @@ import types
from coverage.backward import BUILTINS
from coverage.backward import PYC_MAGIC_NUMBER, imp, importlib_util_find_spec
from coverage.misc import ExceptionDuringRun, NoCode, NoSource
-from coverage.phystokens import open_python_source
+from coverage.phystokens import read_python_source
class DummyLoader(object):
@@ -178,13 +178,10 @@ def make_code_from_py(filename):
"""Get source from `filename` and make a code object of it."""
# Open the source file.
try:
- source_file = open_python_source(filename)
+ source = read_python_source(filename)
except IOError:
raise NoSource("No file to run: %r" % filename)
- with source_file:
- source = source_file.read()
-
# We have the source. `compile` still needs the last line to be clean,
# so make sure it is, then compile a code object from it.
if not source or source[-1] != '\n':