From 4c023d354a34ca0cfc09f3a8b60e85d7f2236e88 Mon Sep 17 00:00:00 2001 From: Bernhard Kaindl Date: Wed, 10 Jul 2024 12:00:00 +0200 Subject: [PATCH] XenAPIPlugin.py: Remove the superflous catch & raise of SystemExit In `XenAPIPlugin.py`'s `dispatch()` function, SystemExit does not need to be caught and raised because both other exceptions are subclasses of Exception: By design, SystemExit is a subclass of BaseException and because we are not catching BaseException and also not use a bare `except:` here, we can cleanup catching and re-raising `SystemExit()` here. Reference: https://docs.python.org/3/library/exceptions.html#SystemExit Signed-off-by: Bernhard Kaindl --- scripts/examples/python/XenAPIPlugin.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/examples/python/XenAPIPlugin.py b/scripts/examples/python/XenAPIPlugin.py index 1d657f065d1..82f1f2f8531 100644 --- a/scripts/examples/python/XenAPIPlugin.py +++ b/scripts/examples/python/XenAPIPlugin.py @@ -44,9 +44,6 @@ def dispatch(fn_table): try: result = fn_table[methodname](x, args) print(success_message(result)) - except SystemExit: - # SystemExit should not be caught, as it is handled elsewhere in the plugin system. - raise except Failure as e: print(failure_message(e.params)) except Exception as e: