svc/connect.in: Change the idiom for handling peer nonexistence.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 28 Apr 2022 14:10:17 +0000 (15:10 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 30 Apr 2022 00:51:38 +0000 (01:51 +0100)
Use `try/except/else' rather than `try/except return'.  It's hardly more
writing for a better code structure.

svc/connect.in

index cb64000..cec1e3f 100644 (file)
@@ -757,12 +757,12 @@ def notify(_, code, *rest):
   """
   if code == 'ADD':
     try: p = Peer(rest[0])
-    except KeyError: return
-    adoptpeer(p, *rest[1:])
+    except KeyError: pass
+    else: adoptpeer(p, *rest[1:])
   elif code == 'KILL':
     try: p = Peer(rest[0])
-    except KeyError: return
-    disownpeer(p, *rest[1:])
+    except KeyError: pass
+    else: disownpeer(p, *rest[1:])
   elif code == 'GREET':
     chal = rest[0]
     try: cr = chalmap[chal]