Browse Source

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>
pr-2391
Rusty Russell 6 years ago
parent
commit
690064f7e0
  1. 4
      contrib/pylightning/lightning/plugin.py

4
contrib/pylightning/lightning/plugin.py

@ -300,7 +300,7 @@ class Plugin(object):
pos = 0 pos = 0
for k, v in arguments.items(): for k, v in arguments.items():
# Skip already assigned args and special catch-all args # 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 continue
if pos < len(params): if pos < len(params):
@ -326,7 +326,7 @@ class Plugin(object):
elif len(args) > 0: elif len(args) > 0:
raise TypeError("Extra arguments given: {args}".format(args=args)) 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: if missing:
raise TypeError("Missing positional arguments ({given} given, " raise TypeError("Missing positional arguments ({given} given, "
"expected {expected}): {missing}".format( "expected {expected}): {missing}".format(

Loading…
Cancel
Save