Fwd: Re: [PATCH] Use binary mode to read .log/.sum
Serhei Makarov
me@serhei.io
Thu Sep 24 01:00:04 GMT 2020
----- Original message -----
From: Serhei Makarov <me@serhei.io>
To: Keith Seitz <keiths@redhat.com>
Subject: Re: [PATCH] Use binary mode to read .log/.sum
Date: Wednesday, September 23, 2020 8:59 PM
On Wed, Sep 23, 2020, at 5:06 PM, Keith Seitz via Bunsen wrote:
> diff --git a/scripts-master/gdb/parse_dejagnu.py
> b/scripts-master/gdb/parse_dejagnu.py
> index 5218e9a..c9f30ac 100755
> --- a/scripts-master/gdb/parse_dejagnu.py
> +++ b/scripts-master/gdb/parse_dejagnu.py
> @@ -65,11 +65,14 @@ def get_outcome_line(testcase):
> datestamp_format = '%a %b %d %H:%M:%S %Y'
>
> def openfile_or_xz(path):
> + # Read in bary mode to suppress encoding problems that might occur
> + # from reading gdb.{log,sum}. Sometimes inferiors or gdb can just output
> + # garbage bytes.
> if os.path.isfile(path):
> - return open(path, mode='rt')
> + return open(path, mode='rb')
> elif os.path.isfile(path+'.xz'):
> - return lzma.open(path+'.xz', mode='rt')
> - return open(path, mode='rt') # XXX trigger default error
> + return lzma.open(path+'.xz', mode='rb')
> + return open(path, mode='rb') # XXX trigger default error
Patch LGTM.
In retrospect, the need to deal with encodings is a major annoyance about I/O in recent Python versions.
I have had to make prior fixes for similar issues, and I'm unsurprised that there is still more to fix.
More information about the Bunsen
mailing list