summary refs log tree commit diff
path: root/synapse/util
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2020-05-22 10:17:36 +0100
committerGitHub <noreply@github.com>2020-05-22 10:17:36 +0100
commita0f99f81b35b0e2ff600d7c72a0d71f15bf94f4c (patch)
tree7025a7126f962d211d08613da8083e69f7ee93c9 /synapse/util
parentmypy for synapse.http.site (#7553) (diff)
downloadsynapse-a0f99f81b35b0e2ff600d7c72a0d71f15bf94f4c.tar.xz
Fix stacktrace mangling in `patch_inline_callbacks` (#7554)
`Failure()` is more cunning than `Failure(e)`.
Diffstat (limited to 'synapse/util')
-rw-r--r--synapse/util/patch_inline_callbacks.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/synapse/util/patch_inline_callbacks.py b/synapse/util/patch_inline_callbacks.py
index fdff195771..2605f3c65b 100644
--- a/synapse/util/patch_inline_callbacks.py
+++ b/synapse/util/patch_inline_callbacks.py
@@ -186,10 +186,15 @@ def _check_yield_points(f: Callable, changes: List[str]):
                     )
                     raise Exception(err)
 
+            # the wrapped function yielded a Deferred: yield it back up to the parent
+            # inlineCallbacks().
             try:
                 result = yield d
-            except Exception as e:
-                result = Failure(e)
+            except Exception:
+                # this will fish an earlier Failure out of the stack where possible, and
+                # thus is preferable to passing in an exeception to the Failure
+                # constructor, since it results in less stack-mangling.
+                result = Failure()
 
             if current_context() != expected_context: