From 1214187b4b301f448c810e2d2bf23ef2fc6370f1 Mon Sep 17 00:00:00 2001 From: keboliu Date: Mon, 4 Jan 2021 13:36:25 +0800 Subject: [PATCH] fix local variable 'lable_port' referenced before assignment error --- .../mellanox/mlnx-platform-api/sonic_platform/sfp_event.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py index 5c57e213a196..ba3ab68a9576 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py @@ -278,6 +278,7 @@ def on_pmpe(self, fd_p): port_cnt_p = new_uint32_t_p() uint32_t_p_assign(port_cnt_p,64) label_port_list = [] + label_port = None module_state = 0 rc = sx_lib_host_ifc_recv(fd_p, pkt, pkt_size_p, recv_info_p) @@ -309,9 +310,11 @@ def on_pmpe(self, fd_p): for i in range(port_cnt): port_attributes = sx_port_attributes_t_arr_getitem(port_attributes_list,i) if port_attributes.log_port == logical_port: - lable_port = port_attributes.port_mapping.module_port + label_port = port_attributes.port_mapping.module_port break - label_port_list.append(lable_port) + + if label_port is not None: + label_port_list.append(label_port) delete_uint32_t_p(pkt_size_p) delete_uint8_t_arr(pkt)