public inbox for bunsen@sourceware.org
 help / color / mirror / Atom feed
* Fwd: Re: [PATCH] Use binary mode to read .log/.sum
@ 2020-09-24  1:00 Serhei Makarov
  2020-09-24 17:47 ` Keith Seitz
  0 siblings, 1 reply; 2+ messages in thread
From: Serhei Makarov @ 2020-09-24  1:00 UTC (permalink / raw)
  To: Bunsen


----- 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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-24 17:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-24  1:00 Fwd: Re: [PATCH] Use binary mode to read .log/.sum Serhei Makarov
2020-09-24 17:47 ` Keith Seitz

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).