Skip to content

Commit

Permalink
pylightning: don't compare v with inspect._empty.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rustyrussell committed Feb 25, 2019
1 parent 6ace13b commit 690064f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contrib/pylightning/lightning/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def _exec_func(self, func, request):
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):
Expand All @@ -326,7 +326,7 @@ def _exec_func(self, func, request):
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(
Expand Down

0 comments on commit 690064f

Please sign in to comment.