mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-08 16:44:22 +01:00
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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user