diff --git a/HISTORY.rst b/HISTORY.rst index 1213db2c3..17e154a67 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -12,6 +12,7 @@ XXXX-XX-XX **Big fixes** - 1105_: [FreeBSD] psutil does not compile on FreeBSD 12. +- 1125_: [BSD] net_connections() raises TypeError. **Compatibility notes** diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py index ba2414cd4..6517f2446 100644 --- a/psutil/_psbsd.py +++ b/psutil/_psbsd.py @@ -394,9 +394,12 @@ def net_connections(kind): # have a very short lifetime so maybe the kernel # can't initialize their status? status = TCP_STATUSES[cext.PSUTIL_CONN_NONE] + if fam in (AF_INET, AF_INET6): + if laddr: + laddr = _common.addr(*laddr) + if raddr: + raddr = _common.addr(*raddr) fam = sockfam_to_enum(fam) - laddr = _common.addr(*laddr) - raddr = _common.addr(*raddr) type = socktype_to_enum(type) nt = _common.sconn(fd, fam, type, laddr, raddr, status, pid) ret.add(nt)