summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-08-01 11:59:03 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2017-08-01 11:59:03 +0200
commit32edf35e95ff1c99ba2f4c94eb9913e65f33bd45 (patch)
treed65dc53b3bf9272e436883215773e7780557ab5f
parent3073311c32b31e4f2b7d1ca2c942bdf476d3b550 (diff)
downloadpsutil-32edf35e95ff1c99ba2f4c94eb9913e65f33bd45.tar.gz
fix TypeError on OSX
-rw-r--r--psutil/_psosx.py6
-rwxr-xr-xpsutil/tests/test_linux.py2
2 files changed, 5 insertions, 3 deletions
diff --git a/psutil/_psosx.py b/psutil/_psosx.py
index 282bdeb4..8093e814 100644
--- a/psutil/_psosx.py
+++ b/psutil/_psosx.py
@@ -485,8 +485,10 @@ class Process(object):
fam = sockfam_to_enum(fam)
type = socktype_to_enum(type)
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)
nt = _common.pconn(fd, fam, type, laddr, raddr, status)
ret.append(nt)
return ret
diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py
index fa2ba023..468b3c66 100755
--- a/psutil/tests/test_linux.py
+++ b/psutil/tests/test_linux.py
@@ -1749,7 +1749,7 @@ class TestProcess(unittest.TestCase):
Cpus_allowed:\tf
Cpus_allowed_list:\t0-7
voluntary_ctxt_switches:\t12
- nonvoluntary_ctxt_switches:\t13"""))
+ nonvoluntary_ctxt_switches:\t13""").encode())
else:
return orig_open(name, *args, **kwargs)