summary refs log tree commit diff
path: root/synapse/events/spamcheck.py
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2021-06-23 17:22:08 +0200
committerGitHub <noreply@github.com>2021-06-23 17:22:08 +0200
commitc955e378683708acd5b88e9cb1980291e06dd9a7 (patch)
tree2bee937b3a8a3ff9e25ce9e5041f07054683d22e /synapse/events/spamcheck.py
parent 1.37.0rc1 (diff)
downloadsynapse-c955e378683708acd5b88e9cb1980291e06dd9a7.tar.xz
Fix wrapping of legacy check_registration_for_spam (#10238)
Fixes #10234
Diffstat (limited to 'synapse/events/spamcheck.py')
-rw-r--r--synapse/events/spamcheck.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/synapse/events/spamcheck.py b/synapse/events/spamcheck.py
index 45ec96dfc1..efec16c226 100644
--- a/synapse/events/spamcheck.py
+++ b/synapse/events/spamcheck.py
@@ -109,6 +109,8 @@ def load_legacy_spam_checkers(hs: "synapse.server.HomeServer"):
             if f is None:
                 return None
 
+            wrapped_func = f
+
             if f.__name__ == "check_registration_for_spam":
                 checker_args = inspect.signature(f)
                 if len(checker_args.parameters) == 3:
@@ -133,19 +135,18 @@ def load_legacy_spam_checkers(hs: "synapse.server.HomeServer"):
                             request_info,
                         )
 
-                    f = wrapper
+                    wrapped_func = wrapper
                 elif len(checker_args.parameters) != 4:
                     raise RuntimeError(
                         "Bad signature for callback check_registration_for_spam",
                     )
 
             def run(*args, **kwargs):
-                # We've already made sure f is not None above, but mypy doesn't do well
-                # across function boundaries so we need to tell it f is definitely not
-                # None.
-                assert f is not None
+                # mypy doesn't do well across function boundaries so we need to tell it
+                # wrapped_func is definitely not None.
+                assert wrapped_func is not None
 
-                return maybe_awaitable(f(*args, **kwargs))
+                return maybe_awaitable(wrapped_func(*args, **kwargs))
 
             return run