From 8bc9798dc7290ed4daa1d05b7a7ebec1a89ecf36 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Tue, 3 Dec 2019 07:30:25 -0700 Subject: [PATCH] rpc.py: add new kv to existing params dict When we get an error when calling an RPC, client.py makes extensive use of the ** operator to add the method and req_id to the params dict variable. This doens't work with Python 2. We don't really support Python 2, but there are at least some folks out there who make their own mods to get rpc.py to work with it. We can very easily implement this in a way that is Python 2 friendly, so let's do that to make it a tiny bit easier for those folks. Incidentally, I do think the changes here also make this part of the code a bit easier to read and understand. Signed-off-by: Jim Harris Change-Id: I1846c80e21032ffba67128bee946b041a61d0621 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/476632 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Alexey Marchuk Reviewed-by: Karol Latecki Reviewed-by: Tomasz Zawadzki --- scripts/rpc/client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/rpc/client.py b/scripts/rpc/client.py index f443e114f..6313787c2 100644 --- a/scripts/rpc/client.py +++ b/scripts/rpc/client.py @@ -158,8 +158,9 @@ class JSONRPCClient(object): raise e if 'error' in response: - msg = "\n".join(["request:", "%s" % json.dumps({**{"method": method, "req_id": req_id}, - **params}, indent=2), + params["method"] = method + params["req_id"] = req_id + msg = "\n".join(["request:", "%s" % json.dumps(params, indent=2), "Got JSON-RPC error response", "response:", json.dumps(response['error'], indent=2)])