protocols.pyon: support artiq.int (fixes #188).

This commit is contained in:
whitequark 2015-12-14 16:26:02 +08:00
parent b5f2e178f6
commit 1860364778
1 changed files with 4 additions and 2 deletions

View File

@ -24,7 +24,7 @@ import os
import tempfile import tempfile
import numpy import numpy
from ..language.core import int as wrapping_int
_encode_map = { _encode_map = {
type(None): "none", type(None): "none",
@ -36,6 +36,7 @@ _encode_map = {
tuple: "tuple", tuple: "tuple",
list: "list", list: "list",
dict: "dict", dict: "dict",
wrapping_int: "number",
Fraction: "fraction", Fraction: "fraction",
OrderedDict: "ordereddict", OrderedDict: "ordereddict",
numpy.ndarray: "nparray" numpy.ndarray: "nparray"
@ -69,7 +70,7 @@ class _Encoder:
return "false" return "false"
def encode_number(self, x): def encode_number(self, x):
return str(x) return repr(x)
def encode_str(self, x): def encode_str(self, x):
# Do not use repr() for JSON compatibility. # Do not use repr() for JSON compatibility.
@ -168,6 +169,7 @@ _eval_dict = {
"false": False, "false": False,
"true": True, "true": True,
"int": wrapping_int,
"Fraction": Fraction, "Fraction": Fraction,
"OrderedDict": OrderedDict, "OrderedDict": OrderedDict,
"nparray": _nparray, "nparray": _nparray,