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]) + ", )"