diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-05-01 13:02:31 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-05-01 13:30:39 -0400 |
commit | 9df434550a499c16e9fd26cfb9627837bfdc02a5 (patch) | |
tree | 5619ea3c3bec05d04363a66ced9c7ebffcefb1df /coverage/files.py | |
parent | 3fe17c1f2244c07cf9d0f9e3609392c2ad441db1 (diff) | |
download | python-coveragepy-git-9df434550a499c16e9fd26cfb9627837bfdc02a5.tar.gz |
refactor: remove code explicitly choosing between py2 and py3
Diffstat (limited to 'coverage/files.py')
-rw-r--r-- | coverage/files.py | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/coverage/files.py b/coverage/files.py index d6826830..f7272bd7 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -13,7 +13,6 @@ import re import sys from coverage import env -from coverage.backward import unicode_class from coverage.misc import contract, CoverageException, join_regex, isolate_module @@ -105,8 +104,6 @@ if env.WINDOWS: def actual_path(path): """Get the actual path of `path`, including the correct case.""" - if env.PY2 and isinstance(path, unicode_class): - path = path.encode(sys.getfilesystemencoding()) if path in _ACTUAL_PATH_CACHE: return _ACTUAL_PATH_CACHE[path] @@ -143,19 +140,10 @@ else: return filename -if env.PY2: - @contract(returns='unicode') - def unicode_filename(filename): - """Return a Unicode version of `filename`.""" - if isinstance(filename, str): - encoding = sys.getfilesystemencoding() or sys.getdefaultencoding() - filename = filename.decode(encoding, "replace") - return filename -else: - @contract(filename='unicode', returns='unicode') - def unicode_filename(filename): - """Return a Unicode version of `filename`.""" - return filename +@contract(filename='unicode', returns='unicode') +def unicode_filename(filename): + """Return a Unicode version of `filename`.""" + return filename @contract(returns='unicode') |