Skip to content

Commit

Permalink
Closes sphinx-doc#5076: [ext/napoleon] explicitly catch StopIteration
Browse files Browse the repository at this point in the history
Per PEP 479, Python 3.7 no longer allows bubbling up StopIteration
outside of a generator. Instead, wrap attribute parsing in a try
block and provide a sane default in case it raises an exception
([]).
  • Loading branch information
michel-slm committed Jun 25, 2018
1 parent e78133a commit 5c4f335
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sphinx/ext/napoleon/docstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,14 @@ def _parse(self):
self._parsed_lines = self._consume_empty()

if self._name and (self._what == 'attribute' or self._what == 'data'):
self._parsed_lines.extend(self._parse_attribute_docstring())
# Implicit stop using StopIteration no longer allowed in
# Python 3.7; see PEP 479
res = []
try:
res = self._parse_attribute_docstring()
except StopIteration as e:
pass
self._parsed_lines.extend(res)
return

while self._line_iter.has_next():
Expand Down

0 comments on commit 5c4f335

Please sign in to comment.