From: Mark Wooding Date: Thu, 28 Apr 2022 14:10:17 +0000 (+0100) Subject: svc/connect.in: Change the idiom for handling peer nonexistence. X-Git-Url: https://git.distorted.org.uk/~mdw/tripe/commitdiff_plain/e9ec9391a095ae55893d521475a01311094b5f98 svc/connect.in: Change the idiom for handling peer nonexistence. Use `try/except/else' rather than `try/except return'. It's hardly more writing for a better code structure. --- diff --git a/svc/connect.in b/svc/connect.in index cb640000..cec1e3ff 100644 --- a/svc/connect.in +++ b/svc/connect.in @@ -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]