Skip to content

Commit 0dbcedd

Browse files
committed
FIX: Windows actually wants strings
1 parent d5be8c0 commit 0dbcedd

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

nipype/utils/filemanip.py

+7-11
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@
2626

2727
fmlogger = logging.getLogger("nipype.utils")
2828

29-
related_filetype_sets = [
30-
(".hdr", ".img", ".mat"),
31-
(".nii", ".mat"),
32-
(".BRIK", ".HEAD"),
33-
]
29+
related_filetype_sets = [(".hdr", ".img", ".mat"), (".nii", ".mat"), (".BRIK", ".HEAD")]
3430

3531

3632
def _resolve_with_filenotfound(path, **kwargs):
@@ -876,7 +872,7 @@ def get_dependencies(name, environ):
876872

877873

878874
def canonicalize_env(env):
879-
"""Windows requires that environment be dicts with bytes as keys and values
875+
"""Windows requires that environment be dicts with str as keys and values
880876
This function converts any unicode entries for Windows only, returning the
881877
dictionary untouched in other environments.
882878
@@ -888,18 +884,18 @@ def canonicalize_env(env):
888884
Returns
889885
-------
890886
env : dict
891-
Windows: environment dictionary with bytes keys and values
887+
Windows: environment dictionary with str keys and values
892888
Other: untouched input ``env``
893889
"""
894890
if os.name != "nt":
895891
return env
896892

897893
out_env = {}
898894
for key, val in env.items():
899-
if not isinstance(key, bytes):
900-
key = key.encode("utf-8")
901-
if not isinstance(val, bytes):
902-
val = val.encode("utf-8")
895+
if not isinstance(key, str):
896+
key = key.decode("utf-8")
897+
if not isinstance(val, str):
898+
val = val.decode("utf-8")
903899
out_env[key] = val
904900
return out_env
905901

0 commit comments

Comments
 (0)