Hi Nis, Others may have some additional comments but a couple of thoughts from an observer (I'm not the maintainer).
C.UTF-8 is provided within glibc (it's in the libc-bin package so it is always available). Is it worth setting that as the locale for all communication with subprocesses? It strikes me that could simplify some parts of this encoding handling. If we're touching every invocation subprocess.* anyway, can we also take this opportunity to get rid of any invocations via the shell? +def get_command_output(cmd): + use_shell = False + if isinstance(cmd, str) and ' ' in cmd: + use_shell = True + return subprocess.run(cmd, shell=use_shell, stdout=subprocess.PIPE).stdout.decode(errors='backslashreplace') specifically, my suggestion is that we *require* cmd to be a list or tuple and always force use_shell=False. Then we never need to worry about nasty characters going near the shell, there's also one less subprocess being used. Associated with that: * redirection of stderr to /dev/null can be done in python instead * the uses of COLUMNS=79 are either no-ops because the command doesn't respect COLUMNS anyway or no-ops because the command ignores COLUMNS when invoked within a pipe. cheers Stuart -- Stuart Prescott http://www.nanonanonano.net/ stu...@nanonanonano.net Debian Developer http://www.debian.org/ stu...@debian.org GPG fingerprint 90E2 D2C1 AD14 6A1B 7EBB 891D BBC1 7EBB 1396 F2F7