forked from M-Labs/artiq
1
0
Fork 0

pyon: handle \r

This commit is contained in:
Sebastien Bourdeauducq 2016-01-27 20:43:42 +01:00
parent b753306f12
commit 590354dbc8
2 changed files with 5 additions and 2 deletions

View File

@ -74,7 +74,10 @@ class _Encoder:
def encode_str(self, x): def encode_str(self, x):
# Do not use repr() for JSON compatibility. # Do not use repr() for JSON compatibility.
tt = {ord("\""): "\\\"", ord("\\"): "\\\\", ord("\n"): "\\n"} tt = {
ord("\""): "\\\"", ord("\\"): "\\\\",
ord("\n"): "\\n", ord("\r"): "\\r"
}
return "\"" + x.translate(tt) + "\"" return "\"" + x.translate(tt) + "\""
def encode_bytes(self, x): def encode_bytes(self, x):

View File

@ -26,7 +26,7 @@ class PYON(unittest.TestCase):
_json_test_object = { _json_test_object = {
"a": "b", "a": "b",
"x": [1, 2, {}], "x": [1, 2, {}],
"foo\nbaz\\qux\"": ["bar", 1.2, {"x": "y"}], "foo\nbaz\\qux\"\r2": ["bar", 1.2, {"x": "y"}],
"bar": [True, False, None] "bar": [True, False, None]
} }