summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2011-01-30 11:56:52 -0500
committerNed Batchelder <ned@nedbatchelder.com>2011-01-30 11:56:52 -0500
commit71a76ea9db424bd5532fcf9d226f552ec290554c (patch)
treeeaa28f2c4fe9c6c572128c439e014442a7b3fa19
parentadf371a94bb59e76502611adafc1fb6640608bf6 (diff)
downloadpython-coveragepy-71a76ea9db424bd5532fcf9d226f552ec290554c.tar.gz
A couple more places to use open_source instead of open(fname, 'rU')
-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 4ac0e3e..d338e15 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 8fbf63b..c61556a 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 3dee80e..60088ae 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: