From af84377e61971aa8ae279b4611ae23dfc6567da8 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 25 Oct 2015 18:13:39 -0400 Subject: Use unicode_filename more, and account for missing filesystemencoding --- coverage/files.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'coverage/files.py') diff --git a/coverage/files.py b/coverage/files.py index 855d815..44997d1 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -67,8 +67,6 @@ def canonical_filename(filename): filename = f break cf = abs_file(filename) - if env.PY2 and isinstance(cf, str): - cf = cf.decode(sys.getfilesystemencoding()) CANONICAL_FILENAME_CACHE[filename] = cf return CANONICAL_FILENAME_CACHE[filename] @@ -135,7 +133,8 @@ if env.PY2: def unicode_filename(filename): """Return a Unicode version of `filename`.""" if isinstance(filename, str): - filename = filename.decode(sys.getfilesystemencoding()) + encoding = sys.getfilesystemencoding() or sys.getdefaultencoding() + filename = filename.decode(encoding, "replace") return filename else: @contract(filename='unicode', returns='unicode') -- cgit v1.2.1