From dfb0735f01c9689fdd7ce1dba3971ca43ff47e9c Mon Sep 17 00:00:00 2001 From: Florian Agbuya Date: Wed, 22 Jan 2025 17:26:43 +0800 Subject: [PATCH] pyon: handle dict subclasses in encode() --- sipyco/pyon.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sipyco/pyon.py b/sipyco/pyon.py index e3be787..cf36234 100644 --- a/sipyco/pyon.py +++ b/sipyco/pyon.py @@ -195,8 +195,11 @@ def encode_npscalar(self, x): def encode(self, x): ty = _encode_map.get(type(x), None) if ty is None: - raise TypeError("`{!r}` ({}) is not PYON serializable" - .format(x, type(x))) + if isinstance(x, dict): + ty = "dict" + else: + raise TypeError("`{!r}` ({}) is not PYON serializable" + .format(x, type(x))) getattr(self, "encode_" + ty)(x)