Skip to content

Commit eae8b20

Browse files
authored
Merge pull request #2617 from mgxd/fix/win
fix: avoid closing file descriptors on windows
2 parents cd5567b + 6e33237 commit eae8b20

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

nipype/interfaces/base/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ def run_command(runtime, output=None, timeout=0.01):
775775
shell=True,
776776
cwd=runtime.cwd,
777777
env=env,
778-
close_fds=True,
778+
close_fds=(not sys.platform.startswith('win')),
779779
)
780780

781781
result = {

nipype/utils/filemanip.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
('.BRIK', '.HEAD'),
3939
]
4040

41+
PY3 = sys.version_info[0] >= 3
4142

4243
class FileNotFoundError(Exception):
4344
pass
@@ -877,12 +878,18 @@ def canonicalize_env(env):
877878
if os.name != 'nt':
878879
return env
879880

881+
# convert unicode to string for python 2
882+
if not PY3:
883+
from future.utils import bytes_to_native_str
880884
out_env = {}
881885
for key, val in env.items():
882886
if not isinstance(key, bytes):
883887
key = key.encode('utf-8')
884888
if not isinstance(val, bytes):
885889
val = val.encode('utf-8')
890+
if not PY3:
891+
key = bytes_to_native_str(key)
892+
val = bytes_to_native_str(val)
886893
out_env[key] = val
887894
return out_env
888895

0 commit comments

Comments
 (0)