From e6023a6fef9f35fb0c7daf331369980537c78bce Mon Sep 17 00:00:00 2001 From: Gaby launay Date: Sun, 28 Mar 2021 21:47:20 +0200 Subject: [PATCH 1/2] Fix #1868: elpy-goto-definition breaks with python 3.9 Original solution from @akshaybadola here: https://github.com/jorgenschaefer/elpy/issues/1868 --- elpy/rpc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/elpy/rpc.py b/elpy/rpc.py index 07b2ce97e..bfa2497ec 100644 --- a/elpy/rpc.py +++ b/elpy/rpc.py @@ -67,6 +67,10 @@ def read_json(self): raise EOFError() return json.loads(line) + def json_defaults(self, x): + if isinstance(x, Path): + return str(x) + def write_json(self, **kwargs): """Write an JSON object on a single line. @@ -74,7 +78,7 @@ def write_json(self, **kwargs): It's not possible with this method to write non-objects. """ - self.stdout.write(json.dumps(kwargs) + "\n") + self.stdout.write(json.dumps(kwargs, default=self.json_defaults) + "\n") self.stdout.flush() def handle_request(self): From 75546d69006a10fa2acb916214c4b3d47a231908 Mon Sep 17 00:00:00 2001 From: galaunay Date: Tue, 20 Apr 2021 00:33:44 +0200 Subject: [PATCH 2/2] Added missing library --- elpy/rpc.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/elpy/rpc.py b/elpy/rpc.py index bfa2497ec..e4277b0dd 100644 --- a/elpy/rpc.py +++ b/elpy/rpc.py @@ -10,6 +10,8 @@ import json import sys import traceback +from pathlib import Path + class JSONRPCServer(object):