diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2022-04-27 09:00:07 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-27 09:00:07 -0400 |
commit | 8a23bde82352f18d7d6f098e3f3f0ce7099efb86 (patch) | |
tree | 69f616cbc1b195490d8c82650db705fc5ea9bfc7 /synapse/events/utils.py | |
parent | Add option to enable token registration without requiring 3pids (#12526) (diff) | |
download | synapse-8a23bde82352f18d7d6f098e3f3f0ce7099efb86.tar.xz |
Consistently use collections.abc.Mapping to check frozendict. (#12564)
Diffstat (limited to 'synapse/events/utils.py')
-rw-r--r-- | synapse/events/utils.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/synapse/events/utils.py b/synapse/events/utils.py index f8d3ba5456..a6c48308b3 100644 --- a/synapse/events/utils.py +++ b/synapse/events/utils.py @@ -27,7 +27,6 @@ from typing import ( ) import attr -from frozendict import frozendict from synapse.api.constants import EventContentFields, EventTypes, RelationTypes from synapse.api.errors import Codes, SynapseError @@ -204,7 +203,9 @@ def _copy_field(src: JsonDict, dst: JsonDict, field: List[str]) -> None: key_to_move = field.pop(-1) sub_dict = src for sub_field in field: # e.g. sub_field => "content" - if sub_field in sub_dict and type(sub_dict[sub_field]) in [dict, frozendict]: + if sub_field in sub_dict and isinstance( + sub_dict[sub_field], collections.abc.Mapping + ): sub_dict = sub_dict[sub_field] else: return @@ -622,7 +623,7 @@ def validate_canonicaljson(value: Any) -> None: # Note that Infinity, -Infinity, and NaN are also considered floats. raise SynapseError(400, "Bad JSON value: float", Codes.BAD_JSON) - elif isinstance(value, (dict, frozendict)): + elif isinstance(value, collections.abc.Mapping): for v in value.values(): validate_canonicaljson(v) |