contrib: Use text=True in subprocess over manual encoding handling
All touched Python scripts already assume and require UTF8, so manually specifying encoding or decoding for functions in the subprocess module is redundant to just using text=True, which exists since Python 3.7
This commit is contained in:
12 files changed
+43
-47
No files matched your search
@@ -27,10 +27,10 @@ def get_shell_files_list():
|
||||
'*.sh',
|
||||
]
|
||||
try:
|
||||
return subprocess.check_output(command, stderr = subprocess.STDOUT).decode('utf-8').splitlines()
|
||||
return subprocess.check_output(command, stderr = subprocess.STDOUT, text=True).splitlines()
|
||||
except subprocess.CalledProcessError as e:
|
||||
if e.returncode > 1: # return code is 1 when match is empty
|
||||
print(e.output.decode('utf-8'), end='')
|
||||
print(e.output, end='')
|
||||
sys.exit(1)
|
||||
return []
|
||||
|
||||
|
||||
Reference in new issue
Block a user