All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Knight <james.d.knight@live.com>
To: Peter Korsgaard <peter@korsgaard.com>
Cc: James Knight <james.d.knight@live.com>, buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH v2 1/1] utils/getdeveloperlib.py: explicitly set devs document encoding
Date: Sat, 18 Sep 2021 22:37:51 -0400	[thread overview]
Message-ID: <CALAjcgWcE9M6qT0uyUHkFwxWGnwx4=wvkPBy+kzD_eX_DTpywg@mail.gmail.com> (raw)
In-Reply-To: <87ilyxshwe.fsf@dell.be.48ers.dk>

Peter,

On Sat, Sep 18, 2021 at 5:17 PM Peter Korsgaard <peter@korsgaard.com> wrote:
> Hmm, this doesn't quite seem to work when stdout is not a UTF-8 console
> ...
>
> ./utils/get-developers -p libyang
> Heiko Thiery <heiko.thiery@gmail.com>
> Jan Kundrát <jan.kundrat@cesnet.cz>
>
> LANG=C ./utils/get-developers -p libyang
> Heiko Thiery <heiko.thiery@gmail.com>
> ...
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 9: ordinal not in range(128)
>
> ./utils/get-developers -p libyang | cat
> ...
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 9: ordinal not in range(128)
>
> Reverting 9f127cc420884ad fixes it:
>
> ./utils/get-developers -p libyang
> Heiko Thiery <heiko.thiery@gmail.com>
> Jan Kundrát <jan.kundrat@cesnet.cz>
>
> LANG=C ./utils/get-developers -p libyang
> Heiko Thiery <heiko.thiery@gmail.com>
> Jan Kundrát <jan.kundrat@cesnet.cz>
>
> ./utils/get-developers -p libyang | cat
> Heiko Thiery <heiko.thiery@gmail.com>
> Jan Kundrát <jan.kundrat@cesnet.cz>
>
> Any idea about how to fix this, or should it just be reverted?

I have no problem with reverting if this is causing issues.

From my (limited) understanding of dealing with encoding, Python and
shells; I may understand the issue here (feel free to correct me if I
am wrong on any of this). I assume that the Python interpreter being
used here is a Python 2.x version. Using the example provided above,
the name value "Kundrát" includes a Unicode character which cannot be
rendered on an ASCII-only supported terminal. For the second command
(the explicit configuration of "LANG=C"), the running Python
interpreter would assume an ASCII terminal, attempt to convert a
unicode string to ASCII and generate the observed exception. Why this
did not fail before this commit was that the Python interpreter would
be processing the name value as a byte string (i.e. not a Unicode
string). The interpreter would just print out the raw byte string to
the output stream and the UTF-8 console would handle/render it as
expected. In the event that these raw bytes are written to an
ASCII-only (or another type of character-only) supported terminal, the
rendered output may not be an expected one (e.g. a value such as
"Kundrát").

I cannot say I understand the output of the third command (I could not
reproduce with the environments I have set up). I assume that maybe
when the call works with the pipe operation, Python may be
auto-detecting the environment as an ASCII output only.

My initial impression of this issue is that it may be better with this
commit, since having the exception thrown would help guarantee that
the output entries would be renderable on the active terminal.
However, if a user is pushing the output to another command that
understands UTF-8, it would be better that the Python interpreter not
throw an exception here and forwarded the raw byte strings (and I
imagine having a user attempting to force "PYTHONIOENCODING" in this
case would be annoying over time) -- so maybe reverting is the best
case here.
_______________________________________________
buildroot mailing list
buildroot@lists.buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

      reply	other threads:[~2021-09-19  2:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-05  1:35 [Buildroot] [PATCH v2 1/1] utils/getdeveloperlib.py: explicitly set devs document encoding James Knight
2021-09-05 14:08 ` Thomas Petazzoni
2021-09-10 11:34 ` Peter Korsgaard
2021-09-10 14:39   ` Baruch Siach
2021-09-10 14:44     ` Peter Korsgaard
2021-09-18 21:17 ` Peter Korsgaard
2021-09-19  2:37   ` James Knight [this message]

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='CALAjcgWcE9M6qT0uyUHkFwxWGnwx4=wvkPBy+kzD_eX_DTpywg@mail.gmail.com' \
    --to=james.d.knight@live.com \
    --cc=buildroot@buildroot.org \
    --cc=peter@korsgaard.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.