Skip to content

Commit

Permalink
Merge pull request #3035 from effigies/fix/filenotfounderror
Browse files Browse the repository at this point in the history
FIX: Drop deprecated message argument to FileNotFoundError
  • Loading branch information
oesteban authored Sep 17, 2019
2 parents 154ea61 + 3e8e376 commit 15a3c15
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions nipype/interfaces/base/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,9 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None):
setattr(outputs, key, val)
except TraitError as error:
if 'an existing' in getattr(error, 'info', 'default'):
msg = "No such file or directory for output '%s' of a %s interface" % \
(key, self.__class__.__name__)
raise FileNotFoundError(val, message=msg)
msg = "No such file or directory '%s' for output '%s' of a %s interface" % \
(val, key, self.__class__.__name__)
raise FileNotFoundError(msg)
raise error
return outputs

Expand Down
18 changes: 10 additions & 8 deletions nipype/utils/filemanip.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@

PY3 = sys.version_info[0] >= 3


class FileNotFoundError(OSError): # noqa
"""Defines the exception for Python 2."""

def __init__(self, path):
"""Initialize the exception."""
super(FileNotFoundError, self).__init__(
2, 'No such file or directory', '%s' % path)
try:
from builtins import FileNotFoundError
except ImportError: # PY27
class FileNotFoundError(OSError): # noqa
"""Defines the exception for Python 2."""

def __init__(self, path):
"""Initialize the exception."""
super(FileNotFoundError, self).__init__(
2, 'No such file or directory', '%s' % path)


USING_PATHLIB2 = False
Expand Down

0 comments on commit 15a3c15

Please sign in to comment.