From e4420a625286ca910f65274d5acdf83d7182e28e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= Date: Thu, 17 Feb 2022 12:56:40 +0000 Subject: [PATCH] fluent.py: prefer simpler return based control flow in _accept rather than relying on raising an exception --- src/test/regress/mitmscripts/fluent.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/test/regress/mitmscripts/fluent.py b/src/test/regress/mitmscripts/fluent.py index eb392ab7c..2fc408e03 100644 --- a/src/test/regress/mitmscripts/fluent.py +++ b/src/test/regress/mitmscripts/fluent.py @@ -20,9 +20,6 @@ logging.basicConfig(format="%(asctime)s %(levelname)s %(message)s", level=loggin # I. Command Strings -class Stop(Exception): - pass - class Handler: ''' This class hierarchy serves two purposes: @@ -46,19 +43,13 @@ class Handler: if not self.next: raise Exception("we don't know what to do!") - try: - self.next._accept(flow, message) - except Stop: + if self.next._accept(flow, message) == 'stop': if self.root is not self: - raise + return 'stop' self.next = KillHandler(self) flow.kill() - elif result == 'done': - # stop processing this packet, move on to the next one - return - elif result == 'stop': - # from now on kill all connections - raise Stop() + else: + return result def _handle(self, flow, message): '''