diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py index fe55f92f2..ba2414cd4 100644 --- a/psutil/_psbsd.py +++ b/psutil/_psbsd.py @@ -719,8 +719,10 @@ def connections(self, kind='inet'): except KeyError: status = TCP_STATUSES[cext.PSUTIL_CONN_NONE] if fam in (AF_INET, AF_INET6): - laddr = _common.addr(*laddr) - raddr = _common.addr(*raddr) + if laddr: + laddr = _common.addr(*laddr) + if raddr: + raddr = _common.addr(*raddr) fam = sockfam_to_enum(fam) type = socktype_to_enum(type) nt = _common.pconn(fd, fam, type, laddr, raddr, status) @@ -737,8 +739,10 @@ def connections(self, kind='inet'): for item in rawlist: fd, fam, type, laddr, raddr, status = item if fam in (AF_INET, AF_INET6): - laddr = _common.addr(*laddr) - raddr = _common.addr(*raddr) + if laddr: + laddr = _common.addr(*laddr) + if raddr: + raddr = _common.addr(*raddr) fam = sockfam_to_enum(fam) type = socktype_to_enum(type) status = TCP_STATUSES[status] diff --git a/psutil/_pssunos.py b/psutil/_pssunos.py index 9931d885f..06e8bbbaa 100644 --- a/psutil/_pssunos.py +++ b/psutil/_pssunos.py @@ -266,8 +266,10 @@ def net_connections(kind, _pid=-1): if type_ not in types: continue if fam in (AF_INET, AF_INET6): - laddr = _common.addr(*laddr) - raddr = _common.addr(*raddr) + if laddr: + laddr = _common.addr(*laddr) + if raddr: + raddr = _common.addr(*raddr) status = TCP_STATUSES[status] fam = sockfam_to_enum(fam) type_ = socktype_to_enum(type_)