Skip to content

Commit 0a7b0a5

Browse files
authored
Merge pull request #2691 from kchawla-pi/incorrect-exception-handling-strip-header
Fixed: Missing substring should raise ValueError not KeyError + try-except code cleanup
2 parents fa0a101 + 7f48e94 commit 0a7b0a5

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

nipype/utils/spm_docs.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ def _strip_header(doc):
5151
cruft = '\x1b'
5252
try:
5353
index = doc.index(hdr)
54-
index += len(hdr)
55-
index += 1
56-
doc = doc[index:]
57-
try:
58-
index = doc.index(cruft)
59-
except ValueError:
60-
index = len(doc)
61-
return doc[:index]
62-
except KeyError as e:
54+
except ValueError as e:
6355
raise_from(IOError('This docstring was not generated by Nipype!\n'), e)
56+
57+
index += len(hdr)
58+
index += 1
59+
doc = doc[index:]
60+
try:
61+
index = doc.index(cruft)
62+
except ValueError:
63+
index = len(doc)
64+
return doc[:index]

0 commit comments

Comments
 (0)