From 368b0e0d16bfaa9bc833c76fbd7945cf5eabcbb3 Mon Sep 17 00:00:00 2001 From: Manoel Brunnen Date: Mon, 10 Jul 2023 12:15:55 +0200 Subject: [PATCH] twister: Initialise unbound 'hardware' variable hardware was referenced as return value, without being declared. When the program goes into the 'except' path, hardware is unbound, but returned, which throws an error: `UnboundLocalError`: local variable 'hardware' referenced before assignment Signed-off-by: Manoel Brunnen --- scripts/pylib/twister/twisterlib/handlers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/pylib/twister/twisterlib/handlers.py b/scripts/pylib/twister/twisterlib/handlers.py index 5af283cbfc4..9a74cc2cb5c 100755 --- a/scripts/pylib/twister/twisterlib/handlers.py +++ b/scripts/pylib/twister/twisterlib/handlers.py @@ -452,6 +452,7 @@ class DeviceHandler(Handler): logger.error("{} timed out".format(script)) def get_hardware(self): + hardware = None try: hardware = self.device_is_available(self.instance) while not hardware: