From f0eed1182ac4d30c7311c94eb1c76357d5ec1543 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 29 Oct 2015 09:42:45 +0800 Subject: [PATCH] protocols/pyon: improve error reporting of non-serializable type --- artiq/protocols/pyon.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/artiq/protocols/pyon.py b/artiq/protocols/pyon.py index 5c25e882c..ee50af99f 100644 --- a/artiq/protocols/pyon.py +++ b/artiq/protocols/pyon.py @@ -132,7 +132,10 @@ class _Encoder: return r def encode(self, x): - return getattr(self, "encode_" + _encode_map[type(x)])(x) + ty = _encode_map.get(type(x), None) + if ty is None: + raise TypeError(repr(x) + " is not PYON serializable") + return getattr(self, "encode_" + ty)(x) def encode(x, pretty=False):