From 443737ec620a699286b9b2e44dbcaac53f553812 Mon Sep 17 00:00:00 2001 From: Yanichkin Alexander Date: Fri, 8 Oct 2021 09:25:31 +0800 Subject: [PATCH] Workaround crashes due to non-UTF-8 characters in process command-lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the Python feature of replacing non-UTF-8 characters with the U+FFFD REPLACEMENT CHARACTER (�). This is only a workaround, a more useful action would be to guess the encoding using chardet or similar and coerce the bytes into Unicode. Fixes: https://bugs.launchpad.net/ubuntu/+source/iotop/+bug/1932523 Fixes: https://bugs.debian.org/737043 Conflict: NA Reference: https://repo.or.cz/iotop.git/commit/443737ec620a699286b9b2e44dbcaac53f553812 --- iotop/data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iotop/data.py b/iotop/data.py index 5d70e29..f5496d0 100644 --- a/iotop/data.py +++ b/iotop/data.py @@ -207,7 +207,7 @@ def find_uids(options): def parse_proc_pid_status(pid): result_dict = {} try: - for line in open('/proc/%d/status' % pid): + for line in open('/proc/%d/status' % pid, errors='replace'): try: key, value = line.split(':', 1) except ValueError: -- 2.33.0