Skip to content

Commit

Permalink
#928: fix possible TypeError
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Aug 1, 2017
1 parent 4672390 commit 5ba055a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 8 additions & 4 deletions psutil/_psbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]
Expand Down
6 changes: 4 additions & 2 deletions psutil/_pssunos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
Expand Down

0 comments on commit 5ba055a

Please sign in to comment.