From c1415e966014e61906d3e426f473768ab8481888 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Thu, 23 Jan 2025 14:40:41 +0100 Subject: [PATCH] don't crash if broadcast_addr() fails --- psutil/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/psutil/__init__.py b/psutil/__init__.py index 6fd88b00f..3bbec9760 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -2242,8 +2242,12 @@ def net_if_addrs(): # On Windows broadcast is None, so we determine it via # ipaddress module. if WINDOWS and fam in {socket.AF_INET, socket.AF_INET6}: - broadcast = _common.broadcast_addr(nt) - nt._replace(broadcast=broadcast) + try: + broadcast = _common.broadcast_addr(nt) + except Exception as err: # noqa: BLE001 + debug(err) + else: + nt._replace(broadcast=broadcast) ret[name].append(nt)