@@ -105,14 +105,19 @@ def _request(self, method, path, postdata):
105105 self .__conn .request (method , path , postdata , headers )
106106 return self ._get_response ()
107107
108+ def _json_dumps (self , obj ):
109+ return json .dumps (obj , default = serialization_fallback , ensure_ascii = self .ensure_ascii )
110+
108111 def get_request (self , * args , ** argsn ):
109112 AuthServiceProxy .__id_count += 1
110113
111- log .debug ("-{}-> {} {}" .format (
114+ log .debug ("-{}-> {} {} {} " .format (
112115 AuthServiceProxy .__id_count ,
113116 self ._service_name ,
114- json .dumps (args or argsn , default = serialization_fallback , ensure_ascii = self .ensure_ascii ),
117+ self ._json_dumps (args ),
118+ self ._json_dumps (argsn ),
115119 ))
120+
116121 if args and argsn :
117122 params = dict (args = args , ** argsn )
118123 else :
@@ -123,7 +128,7 @@ def get_request(self, *args, **argsn):
123128 'id' : AuthServiceProxy .__id_count }
124129
125130 def __call__ (self , * args , ** argsn ):
126- postdata = json . dumps (self .get_request (* args , ** argsn ), default = serialization_fallback , ensure_ascii = self . ensure_ascii )
131+ postdata = self . _json_dumps (self .get_request (* args , ** argsn ))
127132 response , status = self ._request ('POST' , self .__url .path , postdata .encode ('utf-8' ))
128133 # For backwards compatibility tests, accept JSON RPC 1.1 responses
129134 if 'jsonrpc' not in response :
@@ -150,7 +155,7 @@ def __call__(self, *args, **argsn):
150155 return response ['result' ]
151156
152157 def batch (self , rpc_call_list ):
153- postdata = json . dumps (list (rpc_call_list ), default = serialization_fallback , ensure_ascii = self . ensure_ascii )
158+ postdata = self . _json_dumps (list (rpc_call_list ))
154159 log .debug ("--> " + postdata )
155160 response , status = self ._request ('POST' , self .__url .path , postdata .encode ('utf-8' ))
156161 if status != HTTPStatus .OK :
@@ -197,7 +202,7 @@ def _get_response(self):
197202 response = json .loads (responsedata , parse_float = decimal .Decimal )
198203 elapsed = time .time () - req_start_time
199204 if "error" in response and response ["error" ] is None :
200- log .debug ("<-%s- [%.6f] %s" % (response ["id" ], elapsed , json . dumps (response ["result" ], default = serialization_fallback , ensure_ascii = self . ensure_ascii )))
205+ log .debug ("<-%s- [%.6f] %s" % (response ["id" ], elapsed , self . _json_dumps (response ["result" ])))
201206 else :
202207 log .debug ("<-- [%.6f] %s" % (elapsed , responsedata ))
203208 return response , http_response .status
0 commit comments