From 690064f7e03e83d335ce69005eea0b4de4be2764 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 25 Feb 2019 14:45:56 +1030 Subject: [PATCH] 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 --- contrib/pylightning/lightning/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/pylightning/lightning/plugin.py b/contrib/pylightning/lightning/plugin.py index 36ee1f7e4..d7b52dcd8 100644 --- a/contrib/pylightning/lightning/plugin.py +++ b/contrib/pylightning/lightning/plugin.py @@ -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(