Skip to content

Commit

Permalink
FIX: Windows actually wants strings
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Nov 23, 2020
1 parent d5be8c0 commit 0dbcedd
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions nipype/utils/filemanip.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@

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

related_filetype_sets = [
(".hdr", ".img", ".mat"),
(".nii", ".mat"),
(".BRIK", ".HEAD"),
]
related_filetype_sets = [(".hdr", ".img", ".mat"), (".nii", ".mat"), (".BRIK", ".HEAD")]


def _resolve_with_filenotfound(path, **kwargs):
Expand Down Expand Up @@ -876,7 +872,7 @@ def get_dependencies(name, environ):


def canonicalize_env(env):
"""Windows requires that environment be dicts with bytes as keys and values
"""Windows requires that environment be dicts with str as keys and values
This function converts any unicode entries for Windows only, returning the
dictionary untouched in other environments.
Expand All @@ -888,18 +884,18 @@ def canonicalize_env(env):
Returns
-------
env : dict
Windows: environment dictionary with bytes keys and values
Windows: environment dictionary with str keys and values
Other: untouched input ``env``
"""
if os.name != "nt":
return env

out_env = {}
for key, val in env.items():
if not isinstance(key, bytes):
key = key.encode("utf-8")
if not isinstance(val, bytes):
val = val.encode("utf-8")
if not isinstance(key, str):
key = key.decode("utf-8")
if not isinstance(val, str):
val = val.decode("utf-8")
out_env[key] = val
return out_env

Expand Down

0 comments on commit 0dbcedd

Please sign in to comment.