diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-12-13 18:47:18 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-12-13 18:47:18 -0500 |
commit | 5aac8f894f70588612d04607f1b6a3f7123d7aff (patch) | |
tree | 57667aa2605bd1dacbb4e8e415c1defe08401644 /coverage/files.py | |
parent | d4550d57754c90af0bc239c4c0121efab0ea2d09 (diff) | |
download | python-coveragepy-git-5aac8f894f70588612d04607f1b6a3f7123d7aff.tar.gz |
Zip files always produce bytes, and test that we get them decoded properly.
Diffstat (limited to 'coverage/files.py')
-rw-r--r-- | coverage/files.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/coverage/files.py b/coverage/files.py index 1400b6eb..c2d7153d 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -3,7 +3,7 @@ import fnmatch, os, os.path, re, sys import ntpath, posixpath -from coverage.backward import to_string, open_python_source +from coverage.backward import open_python_source from coverage.misc import CoverageException, join_regex @@ -58,7 +58,7 @@ def get_python_source(filename): return f.read() # Maybe it's in a zip file? - source = get_zip_data(filename) + source = get_zip_bytes(filename) if source is not None: return source @@ -68,10 +68,10 @@ def get_python_source(filename): ) -def get_zip_data(filename): +def get_zip_bytes(filename): """Get data from `filename` if it is a zip file path. - Returns the string data read from the zip file, or None if no zip file + Returns the bytestring data read from the zip file, or None if no zip file could be found or `filename` isn't in it. The data returned will be an empty string if the file is empty. @@ -89,7 +89,8 @@ def get_zip_data(filename): data = zi.get_data(parts[1]) except IOError: continue - return to_string(data) + assert isinstance(data, bytes) + return data return None |