Skip to content

Commit 86581c5

Browse files
committed
Use .strerror attribute instead of str() coercion
1 parent e6c1735 commit 86581c5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

nipype/interfaces/io.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def copytree(src, dst, use_hardlink=False):
7171
try:
7272
os.makedirs(dst)
7373
except OSError as why:
74-
if 'File exists' in str(why):
74+
if 'File exists' in why.strerror:
7575
pass
7676
else:
7777
raise why
@@ -86,7 +86,7 @@ def copytree(src, dst, use_hardlink=False):
8686
copyfile(srcname, dstname, True, hashmethod='content',
8787
use_hardlink=use_hardlink)
8888
except (IOError, os.error) as why:
89-
errors.append((srcname, dstname, str(why)))
89+
errors.append((srcname, dstname, why.strerror))
9090
# catch the Error from the recursive copytree so that we can
9191
# continue with other files
9292
except Exception as err:
@@ -687,7 +687,7 @@ def _list_outputs(self):
687687
try:
688688
os.makedirs(outdir)
689689
except OSError as inst:
690-
if 'File exists' in str(inst):
690+
if 'File exists' in inst.strerror:
691691
pass
692692
else:
693693
raise(inst)
@@ -738,7 +738,7 @@ def _list_outputs(self):
738738
try:
739739
os.makedirs(path)
740740
except OSError as inst:
741-
if 'File exists' in str(inst):
741+
if 'File exists' in inst.strerror:
742742
pass
743743
else:
744744
raise(inst)

0 commit comments

Comments
 (0)