Fix bug where we raised StopIteration in a generator

This made python 3.7 unhappy
This commit is contained in:
Erik Johnston 2018-10-17 16:09:34 +01:00
parent d6a7797dd1
commit f6a0a02a62
1 changed files with 5 additions and 2 deletions

View File

@ -596,10 +596,13 @@ def _iterate_over_text(tree, *tags_to_ignore):
# to be returned.
elements = iter([tree])
while True:
el = next(elements)
el = next(elements, None)
if el is None:
return
if isinstance(el, string_types):
yield el
elif el is not None and el.tag not in tags_to_ignore:
elif el.tag not in tags_to_ignore:
# el.text is the text before the first child, so we can immediately
# return it if the text exists.
if el.text: