forked from M-Labs/artiq
pyon: handle \r
This commit is contained in:
parent
b753306f12
commit
590354dbc8
|
@ -74,7 +74,10 @@ class _Encoder:
|
|||
|
||||
def encode_str(self, x):
|
||||
# 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) + "\""
|
||||
|
||||
def encode_bytes(self, x):
|
||||
|
|
|
@ -26,7 +26,7 @@ class PYON(unittest.TestCase):
|
|||
_json_test_object = {
|
||||
"a": "b",
|
||||
"x": [1, 2, {}],
|
||||
"foo\nbaz\\qux\"": ["bar", 1.2, {"x": "y"}],
|
||||
"foo\nbaz\\qux\"\r2": ["bar", 1.2, {"x": "y"}],
|
||||
"bar": [True, False, None]
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue