Skip to content

Commit 04936b7

Browse files
committed
fix: cleaned up based on matthew's feedback
1 parent aeebab1 commit 04936b7

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

nipype/interfaces/base.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,19 +1257,18 @@ def _process(drain=0):
12571257
result['merged'] = [r[1] for r in temp]
12581258
if output == 'allatonce':
12591259
stdout, stderr = proc.communicate()
1260-
if stdout and isinstance(stdout, bytes):
1260+
if isinstance(stdout, bytes):
12611261
try:
12621262
stdout = stdout.decode(locale.getdefaultlocale()[1])
12631263
except UnicodeDecodeError:
12641264
stdout = stdout.decode("ISO-8859-1")
1265-
if stderr and isinstance(stderr, bytes):
1265+
if isinstance(stderr, bytes):
12661266
try:
12671267
stderr = stderr.decode(locale.getdefaultlocale()[1])
12681268
except UnicodeDecodeError:
12691269
stderr = stderr.decode("ISO-8859-1")
1270-
1271-
result['stdout'] = text_type(stdout).split(text_type('\n'))
1272-
result['stderr'] = text_type(stderr).split(text_type('\n'))
1270+
result['stdout'] = stdout.split('\n')
1271+
result['stderr'] = stderr.split('\n')
12731272
result['merged'] = ''
12741273
if output == 'file':
12751274
ret_code = proc.wait()
@@ -1283,8 +1282,8 @@ def _process(drain=0):
12831282
result['stdout'] = []
12841283
result['stderr'] = []
12851284
result['merged'] = ''
1286-
runtime.stderr = text_type('\n').join(result['stderr'])
1287-
runtime.stdout = text_type('\n').join(result['stdout'])
1285+
runtime.stderr = text_type('\n'.join(result['stderr']))
1286+
runtime.stdout = text_type('\n'.join(result['stdout']))
12881287
runtime.merged = result['merged']
12891288
runtime.returncode = proc.returncode
12901289
return runtime

nipype/interfaces/spm/tests/test_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from nipype.interfaces.spm import no_spm
1313
import nipype.interfaces.matlab as mlab
1414
from nipype.interfaces.spm.base import SPMCommandInputSpec
15-
from nipype.interfaces.base import traits
15+
from nipype.interfaces.base import traits, text_type
1616

1717
try:
1818
matlab_cmd = os.environ['MATLABCMD']
@@ -57,7 +57,7 @@ def test_scan_for_fnames():
5757
def test_spm_path():
5858
spm_path = spm.Info.version()['path']
5959
if spm_path is not None:
60-
yield assert_equal, type(spm_path), type('')
60+
yield assert_equal, type(spm_path), text_type
6161
yield assert_true, 'spm' in spm_path
6262

6363

nipype/interfaces/tests/test_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -655,17 +655,17 @@ def test_CommandLine_output():
655655
ci = nib.CommandLine(command='ls -l')
656656
ci.inputs.terminal_output = 'allatonce'
657657
res = ci.run()
658-
yield assert_equal, text_type(res.runtime.merged), text_type('')
658+
yield assert_equal, res.runtime.merged, ''
659659
yield assert_true, name in res.runtime.stdout
660660
ci = nib.CommandLine(command='ls -l')
661661
ci.inputs.terminal_output = 'file'
662662
res = ci.run()
663663
yield assert_true, 'stdout.nipype' in res.runtime.stdout
664-
yield assert_equal, type(text_type(res.runtime.stdout)), type(text_type('hi'))
664+
yield assert_equal, type(res.runtime.stdout), text_type
665665
ci = nib.CommandLine(command='ls -l')
666666
ci.inputs.terminal_output = 'none'
667667
res = ci.run()
668-
yield assert_equal, text_type(res.runtime.stdout), text_type('')
668+
yield assert_equal, res.runtime.stdout, ''
669669
ci = nib.CommandLine(command='ls -l')
670670
res = ci.run()
671671
yield assert_true, 'stdout.nipype' in res.runtime.stdout

0 commit comments

Comments
 (0)