From 6bc8a8bf10e4e7c85b5c8a68de1bc5a95b55e394 Mon Sep 17 00:00:00 2001 From: Xuehai Pan Date: Thu, 4 Jul 2024 16:40:30 +0800 Subject: [PATCH] fix(api/libnvml): gracefully ignore UTF-8 decoding errors --- CHANGELOG.md | 2 +- nvitop/api/device.py | 2 +- nvitop/api/libnvml.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7266be8a..81058edb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- +- Gracefully ignore UTF-8 decoding errors by [@XuehaiPan](https://github.com/XuehaiPan). ### Removed diff --git a/nvitop/api/device.py b/nvitop/api/device.py index f2578095..6b56693c 100644 --- a/nvitop/api/device.py +++ b/nvitop/api/device.py @@ -3146,7 +3146,7 @@ def _parse_cuda_visible_devices( # pylint: disable=too-many-branches,too-many-s ), ], ) - .decode('utf-8') + .decode('utf-8', errors='replace') .strip() .split(',') ) diff --git a/nvitop/api/libnvml.py b/nvitop/api/libnvml.py index fb176670..515ec5ad 100644 --- a/nvitop/api/libnvml.py +++ b/nvitop/api/libnvml.py @@ -461,7 +461,7 @@ def nvmlQuery( raise if isinstance(retval, bytes): - retval = retval.decode('utf-8') + retval = retval.decode('utf-8', errors='replace') return retval