summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-10-17 16:09:34 +0100
committerErik Johnston <erik@matrix.org>2018-10-17 16:10:52 +0100
commitf6a0a02a62db1a3030e5563d6454d01c4a76c38d (patch)
tree040535bcba924ef626776a2b47b12755ddd54819
parentFix roomlist since tokens on Python 3 (#4046) (diff)
downloadsynapse-f6a0a02a62db1a3030e5563d6454d01c4a76c38d.tar.xz
Fix bug where we raised StopIteration in a generator
This made python 3.7 unhappy
-rw-r--r--synapse/rest/media/v1/preview_url_resource.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/synapse/rest/media/v1/preview_url_resource.py b/synapse/rest/media/v1/preview_url_resource.py
index af01040a38..8c892ff187 100644
--- a/synapse/rest/media/v1/preview_url_resource.py
+++ b/synapse/rest/media/v1/preview_url_resource.py
@@ -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: