Skip to content

fix: avoid closing file descriptors on windows #2617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nipype/interfaces/base/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
7 changes: 7 additions & 0 deletions nipype/utils/filemanip.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
('.BRIK', '.HEAD'),
]

PY3 = sys.version_info[0] >= 3

class FileNotFoundError(Exception):
pass
Expand Down Expand Up @@ -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

Expand Down