From ca01be5196ddb3879e924681934485f03f7f192b Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Fri, 3 Feb 2017 18:57:29 +0100 Subject: [PATCH] #966: sensors_battery().power_plugged may erroneously return None on Python 3 --- HISTORY.rst | 2 ++ psutil/_pslinux.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index e55633486..403a2d7de 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,8 @@ **Bug fixes** +- 966_: [Linux] sensors_battery().power_plugged may erroneously return None on + Python 3. - 968_: [Linux] disk_io_counters() raises TypeError on python 3. - 970_: [Linux] sensors_battery()'s name and label fields on Python 3 are bytes instead of str. diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index fdb48f969..beddb8b61 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -1153,7 +1153,7 @@ def multi_cat(*paths): os.path.join(POWER_SUPPLY_PATH, "AC0/online"), fallback=b"0") == b"1" elif os.path.exists(root + "/status"): - status = cat(root + "/status", fallback="").lower() + status = cat(root + "/status", fallback="", binary=False).lower() if status == "discharging": power_plugged = False elif status in ("charging", "full"):