@@ -60,7 +60,7 @@ def __init__(self, rpc_error, http_status=None):
60
60
self .http_status = http_status
61
61
62
62
63
- def EncodeDecimal (o ):
63
+ def serialization_fallback (o ):
64
64
if isinstance (o , decimal .Decimal ):
65
65
return str (o )
66
66
if isinstance (o , pathlib .Path ):
@@ -111,7 +111,7 @@ def get_request(self, *args, **argsn):
111
111
log .debug ("-{}-> {} {}" .format (
112
112
AuthServiceProxy .__id_count ,
113
113
self ._service_name ,
114
- json .dumps (args or argsn , default = EncodeDecimal , ensure_ascii = self .ensure_ascii ),
114
+ json .dumps (args or argsn , default = serialization_fallback , ensure_ascii = self .ensure_ascii ),
115
115
))
116
116
if args and argsn :
117
117
params = dict (args = args , ** argsn )
@@ -123,7 +123,7 @@ def get_request(self, *args, **argsn):
123
123
'id' : AuthServiceProxy .__id_count }
124
124
125
125
def __call__ (self , * args , ** argsn ):
126
- postdata = json .dumps (self .get_request (* args , ** argsn ), default = EncodeDecimal , ensure_ascii = self .ensure_ascii )
126
+ postdata = json .dumps (self .get_request (* args , ** argsn ), default = serialization_fallback , ensure_ascii = self .ensure_ascii )
127
127
response , status = self ._request ('POST' , self .__url .path , postdata .encode ('utf-8' ))
128
128
if response ['error' ] is not None :
129
129
raise JSONRPCException (response ['error' ], status )
@@ -137,7 +137,7 @@ def __call__(self, *args, **argsn):
137
137
return response ['result' ]
138
138
139
139
def batch (self , rpc_call_list ):
140
- postdata = json .dumps (list (rpc_call_list ), default = EncodeDecimal , ensure_ascii = self .ensure_ascii )
140
+ postdata = json .dumps (list (rpc_call_list ), default = serialization_fallback , ensure_ascii = self .ensure_ascii )
141
141
log .debug ("--> " + postdata )
142
142
response , status = self ._request ('POST' , self .__url .path , postdata .encode ('utf-8' ))
143
143
if status != HTTPStatus .OK :
@@ -170,7 +170,7 @@ def _get_response(self):
170
170
response = json .loads (responsedata , parse_float = decimal .Decimal )
171
171
elapsed = time .time () - req_start_time
172
172
if "error" in response and response ["error" ] is None :
173
- log .debug ("<-%s- [%.6f] %s" % (response ["id" ], elapsed , json .dumps (response ["result" ], default = EncodeDecimal , ensure_ascii = self .ensure_ascii )))
173
+ log .debug ("<-%s- [%.6f] %s" % (response ["id" ], elapsed , json .dumps (response ["result" ], default = serialization_fallback , ensure_ascii = self .ensure_ascii )))
174
174
else :
175
175
log .debug ("<-- [%.6f] %s" % (elapsed , responsedata ))
176
176
return response , http_response .status
0 commit comments