Skip to content

Commit c178fbb

Browse files
committed
fix(loadpkl): ensure a value is returned and it is not None
Ref.: #3014 (comment)
1 parent 508df5e commit c178fbb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

nipype/utils/filemanip.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,7 @@ def loadpkl(infile, versioning=False):
682682
pklopen = gzip.open if infile.suffix == '.pklz' else open
683683
pkl_metadata = None
684684

685+
unpkl = None
685686
with indirectory(infile.parent):
686687
pkl_file = pklopen(infile.name, 'rb')
687688

@@ -716,11 +717,14 @@ def loadpkl(infile, versioning=False):
716717
No metadata was found in the pkl file. Make sure you are currently using \
717718
the same Nipype version from the generated pkl.""")
718719
raise e
719-
else:
720-
return unpkl
721720
finally:
722721
pkl_file.close()
723722

723+
if unpkl is None:
724+
raise ValueError('Loading %s resulted in None.' % infile)
725+
726+
return unpkl
727+
724728

725729
def crash2txt(filename, record):
726730
""" Write out plain text crash file """

0 commit comments

Comments
 (0)