From 3c50610f3d453a77dcbfa1df2567a70c67fbc7ea Mon Sep 17 00:00:00 2001 From: Yann Sionneau Date: Wed, 18 Feb 2015 11:18:46 -0700 Subject: [PATCH] pyon: bytes support --- artiq/protocols/pyon.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/artiq/protocols/pyon.py b/artiq/protocols/pyon.py index 161a30615..df7a0fa0c 100644 --- a/artiq/protocols/pyon.py +++ b/artiq/protocols/pyon.py @@ -32,6 +32,7 @@ _encode_map = { int: "number", float: "number", str: "str", + bytes: "bytes", tuple: "tuple", list: "list", dict: "dict", @@ -61,9 +62,13 @@ class _Encoder: return str(x) def encode_str(self, x): + # Do not use repr() for JSON compatibility. tt = {ord("\""): "\\\"", ord("\\"): "\\\\", ord("\n"): "\\n"} return "\"" + x.translate(tt) + "\"" + def encode_bytes(self, x): + return repr(x) + def encode_tuple(self, x): if len(x) == 1: return "(" + self.encode(x[0]) + ", )"