Skip to content

Commit cecdcae

Browse files
mpanaringatesn
authored andcommitted
[IMP] use ujson instead of json (#24)
1 parent 409eb0c commit cecdcae

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

examples/langserver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import json
1+
import ujson as json
22
import logging
33

44
from tornado import web, ioloop, websocket

examples/langserver_ext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import json
1+
import ujson as json
22
import logging
33
import subprocess
44
import threading

pyls_jsonrpc/streams.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copyright 2018 Palantir Technologies, Inc.
2-
import json
2+
import ujson as json
33
import logging
44
import threading
55

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
install_requires=[
3535
'future>=0.14.0',
3636
'futures; python_version<"3.2"',
37+
'ujson<=1.35',
3738
],
3839

3940
# List additional groups of dependencies here (e.g. development

test/test_streams.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,28 @@ def test_writer(wfile, writer):
7878
'params': {}
7979
})
8080
assert wfile.getvalue() == (
81-
b'Content-Length: 49\r\n'
81+
b'Content-Length: 44\r\n'
8282
b'Content-Type: application/vscode-jsonrpc; charset=utf8\r\n'
8383
b'\r\n'
84-
b'{"id": "hello", "method": "method", "params": {}}'
84+
b'{"id":"hello","method":"method","params":{}}'
8585
)
8686

8787

8888
def test_writer_bad_message(wfile, writer):
89-
# A datetime isn't serializable, ensure the write method doesn't throw
89+
# A datetime isn't serializable(or poorly serializable),
90+
# ensure the write method doesn't throw
9091
import datetime
91-
writer.write(datetime.datetime.now())
92-
assert wfile.getvalue() == b''
92+
writer.write(datetime.datetime(
93+
year=2019,
94+
month=1,
95+
day=1,
96+
hour=1,
97+
minute=1,
98+
second=1,
99+
))
100+
assert wfile.getvalue() == (
101+
b'Content-Length: 10\r\n'
102+
b'Content-Type: application/vscode-jsonrpc; charset=utf8\r\n'
103+
b'\r\n'
104+
b'1546304461'
105+
)

0 commit comments

Comments
 (0)