Protect against decoding errors with subprocess text mode
All these are calling subprocess in 'text mode', where it will try to decode stdout/stderr using the default encoding (utf-8 for us). If it doesn't decode, subprocess will raise an exception and kobo doesn't handle it, it just passes it along to us, so things blow up - see https://pagure.io/releng/issue/12474 . To avoid this, let's set `errors="replace"`, which tells the decoder to replace invalid data with ? characters. This way we should get as much of the output as can be read, and no crashes. We also replace `universal_newlines=True` with `text=True` as the latter is shorter, clearer, and what Python 3 subprocess wants us to use, it considers `universal_newlines` to just be a backwards-compatibility thing - "The universal_newlines argument is equivalent to text and is provided for backwards compatibility" Signed-off-by: Adam Williamson <awilliam@redhat.com> Merges: https://pagure.io/pungi/pull-request/1812
This commit is contained in:
parent
98e3b3f8c4
commit
2d16a3af00
17 changed files with 132 additions and 70 deletions
|
|
@ -64,7 +64,8 @@ class Tree(OSTree):
|
|||
show_cmd=True,
|
||||
stdout=True,
|
||||
logfile=log_file,
|
||||
universal_newlines=True,
|
||||
text=True,
|
||||
errors="replace",
|
||||
)
|
||||
finally:
|
||||
os.umask(oldumask)
|
||||
|
|
@ -77,7 +78,8 @@ class Tree(OSTree):
|
|||
show_cmd=True,
|
||||
stdout=True,
|
||||
logfile=log_file,
|
||||
universal_newlines=True,
|
||||
text=True,
|
||||
errors="replace",
|
||||
)
|
||||
|
||||
def _update_ref(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue