Skip to content

Commit 13a7556

Browse files
authored
Merge pull request #3020 from oesteban/maint/3014-related
FIX: Ensure ``loadpkl`` returns a not None value
2 parents 09d55ec + 19ce2c1 commit 13a7556

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: nipype/utils/filemanip.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,7 @@ def loadpkl(infile):
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

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

718+
if unpkl is None:
719+
raise ValueError('Loading %s resulted in None.' % infile)
720+
721+
return unpkl
722+
719723

720724
def crash2txt(filename, record):
721725
""" Write out plain text crash file """

0 commit comments

Comments
 (0)