summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2017-07-05 00:28:43 +0100
committerRichard van der Hoff <richard@matrix.org>2017-07-05 00:28:43 +0100
commit73cfe48031cb67f294a5a99e6661f584b14dc10f (patch)
tree0edf4a9dd870ad56d4509d984fd1f1f50455d323 /synapse
parentFix typo when getting app name (diff)
downloadsynapse-73cfe48031cb67f294a5a99e6661f584b14dc10f.tar.xz
Fix caching error in the push evaluator
Initialising `result` to `{}` in the parameters meant that every call to
_flatten_dict used the *same* target dictionary.

I'm hopeful this will fix https://github.com/matrix-org/synapse/issues/2270,
but I suspect it won't. (This code seems to have been here since forever,
unlike the bug, and I don't really think it explains the observed
behaviour). Still, it makes it hard to investigate the problem.
Diffstat (limited to 'synapse')
-rw-r--r--synapse/push/push_rule_evaluator.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/synapse/push/push_rule_evaluator.py b/synapse/push/push_rule_evaluator.py
index 4d88046579..172c27c137 100644
--- a/synapse/push/push_rule_evaluator.py
+++ b/synapse/push/push_rule_evaluator.py
@@ -200,7 +200,9 @@ def _glob_to_re(glob, word_boundary):
         return re.compile(r, flags=re.IGNORECASE)
 
 
-def _flatten_dict(d, prefix=[], result={}):
+def _flatten_dict(d, prefix=[], result=None):
+    if result is None:
+        result = {}
     for key, value in d.items():
         if isinstance(value, basestring):
             result[".".join(prefix + [key])] = value.lower()