Skip to content

linux: handle missing /sys/class/power_supply in sensors_battery() - #2595

Open
bdrung wants to merge 1 commit into
giampaolo:masterfrom
bdrung:missing-power-supply
Open

bdrung wants to merge 1 commit into
giampaolo:masterfrom
bdrung:missing-power-supply

Conversation

@bdrung

@bdrung bdrung commented Jun 30, 2025

Copy link
Copy Markdown
Contributor

Summary

Description

The test TestModuleFunctionsLeaks.test_sensors_battery fails on Ubuntu s390x in sensors_battery with:

FileNotFoundError: [Errno 2] No such file or directory: '/sys/class/power_supply'

Fix sensors_battery to return None in case POWER_SUPPLY_PATH does not exist.

@bdrung
bdrung force-pushed the missing-power-supply branch from bdedc8b to b7bb733 Compare June 30, 2025 12:01
@bdrung
bdrung force-pushed the missing-power-supply branch from b7bb733 to 11fa37b Compare October 17, 2025 12:55
The test `TestModuleFunctionsLeaks.test_sensors_battery` fails on Ubuntu
s390x in `sensors_battery` with:

```
FileNotFoundError: [Errno 2] No such file or directory: '/sys/class/power_supply'
```

Fix `sensors_battery` to return `None` in case `POWER_SUPPLY_PATH` does
not exist.

Fixes: giampaolo#2067
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
@bdrung
bdrung force-pushed the missing-power-supply branch from 11fa37b to 7dcea77 Compare October 21, 2025 09:08
@giampaolo giampaolo added bug type linux platform : Linux specific critical process dies, hangs forever, or memory is corrupt: segfault, deadlock, double free, crash on import badexc psutil raises something other than NoSuchProcess, AccessDenied, ZombieProcess or TimeoutExpired and removed critical process dies, hangs forever, or memory is corrupt: segfault, deadlock, double free, crash on import labels Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

badexc psutil raises something other than NoSuchProcess, AccessDenied, ZombieProcess or TimeoutExpired bug type linux platform : Linux specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Linux/Docker] hasattr(psutil, 'sensors_battery') returns True even when a battery isn't available:

2 participants