Skip to content
Snippets Groups Projects
Unverified Commit 4e726783 authored by Erik Johnston's avatar Erik Johnston Committed by GitHub
Browse files

Merge pull request #4050 from matrix-org/erikj/fix_py37_iteration

Fix bug where we raised StopIteration in a generator
parents d6a7797d 3a5d8d58
No related branches found
No related tags found
No related merge requests found
Fix URL priewing to work in Python 3.7
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment