Skip to content

Commit 07d598a

Browse files
author
Ben Cipollini
committed
fix: make sure stdout/stderr are of python version's string type.
1 parent 63566a9 commit 07d598a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

nipype/interfaces/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ def run_command(runtime, output=None, timeout=0.01, redirect_x=False):
12121212
if output == 'file':
12131213
errfile = os.path.join(runtime.cwd, 'stderr.nipype')
12141214
outfile = os.path.join(runtime.cwd, 'stdout.nipype')
1215-
stderr = open(errfile, 'wt')
1215+
stderr = open(errfile, 'wt') # t=='text'===default
12161216
stdout = open(outfile, 'wt')
12171217

12181218
proc = subprocess.Popen(cmdline,
@@ -1263,8 +1263,8 @@ def _process(drain=0):
12631263
result['merged'] = [r[1] for r in temp]
12641264
if output == 'allatonce':
12651265
stdout, stderr = proc.communicate()
1266-
result['stdout'] = stdout.decode().split('\n')
1267-
result['stderr'] = stderr.decode().split('\n')
1266+
result['stdout'] = str(stdout).split('\n')
1267+
result['stderr'] = str(stderr).split('\n')
12681268
result['merged'] = ''
12691269
if output == 'file':
12701270
ret_code = proc.wait()

nipype/interfaces/tests/test_base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ def test_CommandLine_output():
621621
ci.inputs.terminal_output = 'file'
622622
res = ci.run()
623623
yield assert_true, 'stdout.nipype' in res.runtime.stdout
624+
yield assert_equal, type(res.runtime.stdout), type('hi')
624625
ci = nib.CommandLine(command='ls -l')
625626
ci.inputs.terminal_output = 'none'
626627
res = ci.run()

0 commit comments

Comments
 (0)