diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2022-01-16 12:41:25 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2022-01-16 12:41:25 +0100 |
commit | 7803582ae7a331e3a0be367cae377c92f294148d (patch) | |
tree | 929367bc8ecfecbb85c600438087161601ec14d3 /psutil | |
parent | d135e2c3a99bfd1bd01d1158ec31dbc8dc1c910f (diff) | |
download | psutil-7803582ae7a331e3a0be367cae377c92f294148d.tar.gz |
fix py 2.7 failures
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
Diffstat (limited to 'psutil')
-rw-r--r-- | psutil/_common.py | 4 | ||||
-rwxr-xr-x | psutil/tests/test_linux.py | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/psutil/_common.py b/psutil/_common.py index c94a8378..00a9c6fd 100644 --- a/psutil/_common.py +++ b/psutil/_common.py @@ -289,7 +289,9 @@ class Error(Exception): info = {} # Python 2.6 for name in attrs: value = getattr(self, name, None) - if value is not None: + if value: + info[name] = value + elif name == "pid" and value == 0: info[name] = value return info diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index 2f8c40b0..e36fb874 100755 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -1911,7 +1911,7 @@ class TestProcess(PsutilTestCase): patch_point = 'psutil._pslinux.os.readlink' with mock.patch(patch_point, side_effect=OSError(errno.ENAMETOOLONG, "")) as m: - with mock.patch("psutil._common.debug"): + with mock.patch("psutil._pslinux.debug"): files = p.open_files() assert not files assert m.called @@ -2156,7 +2156,7 @@ class TestProcess(PsutilTestCase): with mock.patch('psutil._pslinux.os.readlink', side_effect=OSError(errno.ENAMETOOLONG, "")) as m: p = psutil.Process() - with mock.patch("psutil._common.debug"): + with mock.patch("psutil._pslinux.debug"): assert not p.connections() assert m.called |