diff --git a/elpy/rpc.py b/elpy/rpc.py index 07b2ce97e..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): @@ -67,6 +69,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 +80,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):