niligulmohar/python-symmetric-jsonrpc — Issue #8: enhancement: questionable default value for params
Author: kroeplin
Created: 2011-11-22 16:31:03+00:00
State: open

The methods 'request' and 'notify' of the class 'RPCClient' in 'rpc.py' use an empty array as default value for 'params'.

The specification states: "This member MAY be omitted."

With a default value of 'None' the following code (with ugly repetition?) would send better requests without parameters:

if params is None:
self.writer.write_value({'jsonrpc': '2.0', 'method': method, 'id': request_id})
else:
self.writer.write_value({'jsonrpc': '2.0', 'method': method, 'params': params, 'id': request_id})

and

if params is None:
self.writer.write_value({'method': method})
else:
self.writer.write_value({'method': method, 'params': params})

(By the way: the 'jsonrpc': '2.0' part is currently missing for notifications.)