Sun, 04 Oct 2015 22:54:47 +0200
coverage fix for unicode problems in path names.
DebugClients/Python/coverage/data.py | file | annotate | diff | comparison | revisions | |
DebugClients/Python/coverage/files.py | file | annotate | diff | comparison | revisions |
--- a/DebugClients/Python/coverage/data.py Sun Oct 04 22:37:56 2015 +0200 +++ b/DebugClients/Python/coverage/data.py Sun Oct 04 22:54:47 2015 +0200 @@ -11,6 +11,7 @@ import random import re import socket +import sys from coverage import env from coverage.backward import iitems, string_class @@ -269,10 +270,15 @@ self._lines = self._arcs = None if 'lines' in data: - self._lines = data['lines'] + self._lines = dict( + (fname.encode(sys.getfilesystemencoding()), linenos) + for fname, linenos in iitems(data['lines']) + ) + if 'arcs' in data: self._arcs = dict( - (fname, [tuple(pair) for pair in arcs]) + (fname.encode(sys.getfilesystemencoding()), + [tuple(pair) for pair in arcs]) for fname, arcs in iitems(data['arcs']) ) self._file_tracers = data.get('file_tracers', {}) @@ -284,15 +290,8 @@ """Read the coverage data from `filename` into this object.""" if self._debug and self._debug.should('dataio'): self._debug.write("Reading data from %r" % (filename,)) - try: - with self._open_for_reading(filename) as f: - self.read_fileobj(f) - except Exception as exc: - raise CoverageException( - "Couldn't read data from '%s': %s: %s" % ( - filename, exc.__class__.__name__, exc, - ) - ) + with self._open_for_reading(filename) as f: + self.read_fileobj(f) _GO_AWAY = "!coverage.py: This is a private format, don't read it directly!" @@ -434,10 +433,17 @@ file_data = {} if self._has_arcs(): - file_data['arcs'] = self._arcs + file_data['arcs'] = dict( + (fname.decode(sys.getfilesystemencoding()), + [tuple(pair) for pair in self._arcs]) + for fname, arcs in iitems(data['arcs']) + ) if self._has_lines(): - file_data['lines'] = self._lines + file_data['lines'] = dict( + (fname.decode(sys.getfilesystemencoding()), linenos) + for fname, linenos in iitems(self._lines) + ) if self._file_tracers: file_data['file_tracers'] = self._file_tracers @@ -750,3 +756,6 @@ if __name__ == '__main__': import sys debug_main(sys.argv[1:]) + +# +# eflag: FileType = Python2
--- a/DebugClients/Python/coverage/files.py Sun Oct 04 22:37:56 2015 +0200 +++ b/DebugClients/Python/coverage/files.py Sun Oct 04 22:54:47 2015 +0200 @@ -58,7 +58,7 @@ for path in [os.curdir] + sys.path: if path is None: continue - f = os.path.join(path, filename) + f = path + os.sep + filename if os.path.exists(f): filename = f break @@ -114,7 +114,7 @@ if os.path.normcase(f) == normtail: tail = f break - actpath = os.path.join(head, tail) + actpath = head.strip(os.sep) + os.sep + tail _ACTUAL_PATH_CACHE[path] = actpath return actpath @@ -349,4 +349,7 @@ # files: Must end with .py or .pyw, and must not have certain funny # characters that probably mean they are editor junk. if re.match(r"^[^.#~!$@%^&*()+=,]+\.pyw?$", filename): - yield os.path.join(dirpath, filename) + yield dirpath + os.sep + filename + +# +# eflag: FileType = Python2