Skip to content

FIX: Ensure loadpkl returns a not None value #3020

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 1 commit into from
Sep 6, 2019
Merged
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
8 changes: 6 additions & 2 deletions nipype/utils/filemanip.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ def loadpkl(infile):
pklopen = gzip.open if infile.suffix == '.pklz' else open
pkl_metadata = None

unpkl = None
with indirectory(infile.parent):
pkl_file = pklopen(infile.name, 'rb')

Expand Down Expand Up @@ -711,11 +712,14 @@ def loadpkl(infile):
No metadata was found in the pkl file. Make sure you are currently using \
the same Nipype version from the generated pkl.""")
raise e
else:
return unpkl
finally:
pkl_file.close()

if unpkl is None:
raise ValueError('Loading %s resulted in None.' % infile)

return unpkl


def crash2txt(filename, record):
""" Write out plain text crash file """
Expand Down