pylightning: don't compare v with inspect._empty.

I originally converted input JSON naively into Millisatoshi, and the
result was a strange failure in Millisatoshi.__eq__.

It seems this is because inspect._empty.__eq__(Millisatoshi) raises
NotImplemented, and so it tries Millisatoshi.__eq__(inspect._empty)
which doesn't like it.

'is' is the correct test here, AFAICT, and doesn't suffer from these
problems.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-02-25 14:45:56 +10:30
parent 6ace13ba22
commit 690064f7e0

View File

@@ -300,7 +300,7 @@ class Plugin(object):
pos = 0
for k, v in arguments.items():
# Skip already assigned args and special catch-all args
if v != inspect._empty or k in ['args', 'kwargs']:
if v is not inspect._empty or k in ['args', 'kwargs']:
continue
if pos < len(params):
@@ -326,7 +326,7 @@ class Plugin(object):
elif len(args) > 0:
raise TypeError("Extra arguments given: {args}".format(args=args))
missing = [k for k, v in arguments.items() if v == inspect._empty]
missing = [k for k, v in arguments.items() if v is inspect._empty]
if missing:
raise TypeError("Missing positional arguments ({given} given, "
"expected {expected}): {missing}".format(