From 07c6b40f8ba4f7214a09dc5914a656306cf33783 Mon Sep 17 00:00:00 2001 From: yeger Date: Fri, 11 Jan 2019 14:00:40 -0500 Subject: [PATCH] fixing decode in python3 --- examples/clangd.py | 4 ++-- pylspclient/json_rpc_endpoint.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/clangd.py b/examples/clangd.py index 51725f4..d743193 100644 --- a/examples/clangd.py +++ b/examples/clangd.py @@ -9,10 +9,10 @@ class ReadPipe(threading.Thread): self.pipe = pipe def run(self): - line = self.pipe.readline() + line = self.pipe.readline().decode('utf-8') while line: print(line) - line = self.pipe.readline() + line = self.pipe.readline().decode('utf-8') if __name__ == "__main__": clangd_path = "/usr/bin/clangd-6.0" diff --git a/pylspclient/json_rpc_endpoint.py b/pylspclient/json_rpc_endpoint.py index 003308d..4271b32 100644 --- a/pylspclient/json_rpc_endpoint.py +++ b/pylspclient/json_rpc_endpoint.py @@ -62,7 +62,7 @@ class JsonRpcEndpoint(object): line = self.stdout.readline() if not line: return None - line = line.decode() + line = line.decode('utf-8') # TODO: handle content type as well. match = re.match(JSON_RPC_RES_REGEX, line) if match is None or not match.groups(): @@ -71,8 +71,8 @@ class JsonRpcEndpoint(object): line = self.stdout.readline() if not line: return None - line = line.decode() + line = line.decode('utf-8') if line != "\r\n": raise RuntimeError("Bad header: missing newline") - jsonrpc_res = self.stdout.read(size) + jsonrpc_res = self.stdout.read(size).decode('utf-8') return json.loads(jsonrpc_res)