mirror of
https://github.com/element-hq/synapse
synced 2024-09-04 17:10:06 +00:00
Merge pull request #4050 from matrix-org/erikj/fix_py37_iteration
Fix bug where we raised StopIteration in a generator
This commit is contained in:
commit
4e726783ea
2 changed files with 6 additions and 2 deletions
1
changelog.d/4050.bugfix
Normal file
1
changelog.d/4050.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix URL priewing to work in Python 3.7
|
|
@ -596,10 +596,13 @@ def _iterate_over_text(tree, *tags_to_ignore):
|
||||||
# to be returned.
|
# to be returned.
|
||||||
elements = iter([tree])
|
elements = iter([tree])
|
||||||
while True:
|
while True:
|
||||||
el = next(elements)
|
el = next(elements, None)
|
||||||
|
if el is None:
|
||||||
|
return
|
||||||
|
|
||||||
if isinstance(el, string_types):
|
if isinstance(el, string_types):
|
||||||
yield el
|
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
|
# el.text is the text before the first child, so we can immediately
|
||||||
# return it if the text exists.
|
# return it if the text exists.
|
||||||
if el.text:
|
if el.text:
|
||||||
|
|
Loading…
Reference in a new issue