From 1776ed43c565258215b695da11d54d9e3b8c4c2c Mon Sep 17 00:00:00 2001 From: mathiasg Date: Tue, 12 Jun 2018 12:28:42 -0400 Subject: [PATCH 1/2] avoid unsupported operation on windows --- nipype/interfaces/base/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/interfaces/base/core.py b/nipype/interfaces/base/core.py index e5c7fb2ca6..84363eb0be 100644 --- a/nipype/interfaces/base/core.py +++ b/nipype/interfaces/base/core.py @@ -775,7 +775,7 @@ def run_command(runtime, output=None, timeout=0.01): shell=True, cwd=runtime.cwd, env=env, - close_fds=True, + close_fds=(not sys.platform.startswith('win')), ) result = { From 6e3323750aca8a7e3da8fef9947ae31dd52d6fff Mon Sep 17 00:00:00 2001 From: mathiasg Date: Tue, 12 Jun 2018 13:33:05 -0400 Subject: [PATCH 2/2] fix: ensure env values are strings in py2 --- nipype/utils/filemanip.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nipype/utils/filemanip.py b/nipype/utils/filemanip.py index 1e4db4c6b1..c7458fa5d8 100644 --- a/nipype/utils/filemanip.py +++ b/nipype/utils/filemanip.py @@ -38,6 +38,7 @@ ('.BRIK', '.HEAD'), ] +PY3 = sys.version_info[0] >= 3 class FileNotFoundError(Exception): pass @@ -877,12 +878,18 @@ def canonicalize_env(env): if os.name != 'nt': return env + # convert unicode to string for python 2 + if not PY3: + from future.utils import bytes_to_native_str 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 PY3: + key = bytes_to_native_str(key) + val = bytes_to_native_str(val) out_env[key] = val return out_env