mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Update utility code to handle C implementations of frozendict (#10902)
* update _handle_frozendict to work with c implementations of frozen dict * add changelog * add clarifying comment to _handle_frozendict
This commit is contained in:
parent
8aaa4b7b5d
commit
0f007fe009
1
changelog.d/10902.misc
Normal file
1
changelog.d/10902.misc
Normal file
@ -0,0 +1 @@
|
||||
Update utility code to handle C implementations of frozendict.
|
@ -50,7 +50,13 @@ def _handle_frozendict(obj: Any) -> Dict[Any, Any]:
|
||||
if type(obj) is frozendict:
|
||||
# fishing the protected dict out of the object is a bit nasty,
|
||||
# but we don't really want the overhead of copying the dict.
|
||||
return obj._dict
|
||||
try:
|
||||
return obj._dict
|
||||
except AttributeError:
|
||||
# When the C implementation of frozendict is used,
|
||||
# there isn't a `_dict` attribute with a dict
|
||||
# so we resort to making a copy of the frozendict
|
||||
return dict(obj)
|
||||
raise TypeError(
|
||||
"Object of type %s is not JSON serializable" % obj.__class__.__name__
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user