Commit 9363ee42 authored by Jason R. Coombs's avatar Jason R. Coombs

Extract variable for candidate encodings

parent 25a12d49
...@@ -22,11 +22,13 @@ def filesys_decode(path): ...@@ -22,11 +22,13 @@ def filesys_decode(path):
NONE when no expected encoding works NONE when no expected encoding works
""" """
fs_enc = sys.getfilesystemencoding()
if isinstance(path, six.text_type): if isinstance(path, six.text_type):
return path return path
for enc in (fs_enc, "utf-8"): fs_enc = sys.getfilesystemencoding()
candidates = fs_enc, 'utf-8'
for enc in candidates:
try: try:
return path.decode(enc) return path.decode(enc)
except UnicodeDecodeError: except UnicodeDecodeError:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment