Skip to content

Commit 7d5639e

Browse files
committed
FIX: Windows actually wants strings
1 parent 980ef5d commit 7d5639e

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

nipype/utils/filemanip.py

Lines changed: 7 additions & 11 deletions
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):
@@ -878,7 +874,7 @@ def get_dependencies(name, environ):
878874

879875

880876
def canonicalize_env(env):
881-
"""Windows requires that environment be dicts with bytes as keys and values
877+
"""Windows requires that environment be dicts with str as keys and values
882878
This function converts any unicode entries for Windows only, returning the
883879
dictionary untouched in other environments.
884880
@@ -890,18 +886,18 @@ def canonicalize_env(env):
890886
Returns
891887
-------
892888
env : dict
893-
Windows: environment dictionary with bytes keys and values
889+
Windows: environment dictionary with str keys and values
894890
Other: untouched input ``env``
895891
"""
896892
if os.name != "nt":
897893
return env
898894

899895
out_env = {}
900896
for key, val in env.items():
901-
if not isinstance(key, bytes):
902-
key = key.encode("utf-8")
903-
if not isinstance(val, bytes):
904-
val = val.encode("utf-8")
897+
if not isinstance(key, str):
898+
key = key.decode("utf-8")
899+
if not isinstance(val, str):
900+
val = val.decode("utf-8")
905901
out_env[key] = val
906902
return out_env
907903

0 commit comments

Comments
 (0)