From 873e7d51b8bcaf5762a985cf7fe125a1e177ea4a Mon Sep 17 00:00:00 2001 From: lars-devs <55888759+lars-devs@users.noreply.github.com> Date: Mon, 2 Sep 2024 22:10:38 +0200 Subject: [PATCH] Exit battery sensor retrival if path is non-existent --- psutil/_pslinux.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index 167183881..78052f5dd 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -1530,6 +1530,9 @@ def sensors_battery(): meaning but under different names, see: https://github.com/giampaolo/psutil/issues/966. """ + if not os.path.isdir(POWER_SUPPLY_PATH): + return None + null = object() def multi_bcat(*paths):