Skip to content

Commit

Permalink
[FIX] Use resp.get() to prevent KeyError
Browse files Browse the repository at this point in the history
Whenever a JSON RPC call returns `None`, the `result` key in the response will not exist, and therefore it will trigger a KeyError. By using get(), None is returned if the the 'result' key does not exist.

Fixes tinyerp#8
  • Loading branch information
Daniel Libonati authored Jan 2, 2020
1 parent 0d37769 commit 57a7eb5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion odooly.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def dispatch_jsonrpc(url, service_name, method, args):
resp = http_post(url, json.dumps(data).encode('ascii'))
if resp.get('error'):
raise ServerError(resp['error'])
return resp['result']
return resp.get('result')


class partial(functools.partial):
Expand Down

0 comments on commit 57a7eb5

Please sign in to comment.