summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt5
-rw-r--r--coverage/execfile.py4
-rw-r--r--coverage/parser.py2
3 files changed, 8 insertions, 3 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 4ac0e3e0..d338e155 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -19,11 +19,16 @@ Version 3.5
coverage.py will issue a warning, at least alerting you to the problem.
Closes `issue 93`_. Thanks to Marius Gedminas for the idea.
+- Source files are now opened with Python 3.2's ``tokenize.open()`` where
+ possible, to get the best handling of Python source files with encodings.
+ Closes `issue 107`, thanks, Brett Cannon.
+
- Internally, files are now closed explicitly, fixing `issue 104`. Thanks,
Brett Cannon.
.. _issue 93: http://bitbucket.org/ned/coveragepy/issue/93/copying-a-mock-object-breaks-coverage
.. _issue 104: https://bitbucket.org/ned/coveragepy/issue/104/explicitly-close-files
+.. _issue 107: https://bitbucket.org/ned/coveragepy/issue/107/codeparser-not-opening-source-files-with
Version 3.4 --- 19 September 2010
diff --git a/coverage/execfile.py b/coverage/execfile.py
index 8fbf63b8..c61556ac 100644
--- a/coverage/execfile.py
+++ b/coverage/execfile.py
@@ -2,7 +2,7 @@
import imp, os, sys
-from coverage.backward import exec_code_object
+from coverage.backward import exec_code_object, open_source
from coverage.misc import NoSource, ExceptionDuringRun
@@ -38,7 +38,7 @@ def run_python_file(filename, args):
try:
# Open the source file.
try:
- source_file = open(filename, 'rU')
+ source_file = open_source(filename)
except IOError:
raise NoSource("No file to run: %r" % filename)
diff --git a/coverage/parser.py b/coverage/parser.py
index 3dee80eb..60088ae8 100644
--- a/coverage/parser.py
+++ b/coverage/parser.py
@@ -304,7 +304,7 @@ class ByteParser(object):
else:
if not text:
assert filename, "If no code or text, need a filename"
- sourcef = open(filename, 'rU')
+ sourcef = open_source(filename)
try:
text = sourcef.read()
finally: