From: "Serhei Makarov" <me@serhei.io>
To: Bunsen <bunsen@sourceware.org>
Subject: Fwd: Re: [PATCH] Use binary mode to read .log/.sum
Date: Wed, 23 Sep 2020 21:00:04 -0400 [thread overview]
Message-ID: <97957952-514b-4186-9cac-93fe07517309@www.fastmail.com> (raw)
----- 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.
next reply other threads:[~2020-09-24 1:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-24 1:00 Serhei Makarov [this message]
2020-09-24 17:47 ` Keith Seitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=97957952-514b-4186-9cac-93fe07517309@www.fastmail.com \
--to=me@serhei.io \
--cc=bunsen@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).