Message ID | 20210917162332.3511179-7-alex.bennee@linaro.org |
---|---|
State | New |
Headers | show |
Series | testing and plugin pre-PR (configure, gitlab, plugins) | expand |
Hi, I sent a PR for this (and an additional fix that is needed as of yesterday): https://lists.gnu.org/archive/html/qemu-devel/2021-09/msg04477.html Please drop this patch and prefer that series. --js On Fri, Sep 17, 2021 at 12:23 PM Alex Bennée <alex.bennee@linaro.org> wrote: > From: John Snow <jsnow@redhat.com> > > A few new annoyances. Of note is the new warning for an unspecified > encoding when opening a text file, which actually does indicate a > potentially real problem; see > https://www.python.org/dev/peps/pep-0597/#motivation > > Use LC_CTYPE to determine an encoding to use for interpreting QEMU's > terminal output. Note that Python states: "language code and encoding > may be None if their values cannot be determined" -- use a platform > default as a backup. > > Signed-off-by: John Snow <jsnow@redhat.com> > Message-Id: <20210916040955.628560-2-jsnow@redhat.com> > Reviewed-by: Alex Bennée <alex.bennee@linaro.org> > Tested-by: Alex Bennée <alex.bennee@linaro.org> > Signed-off-by: Alex Bennée <alex.bennee@linaro.org> > --- > python/qemu/machine/machine.py | 9 ++++++++- > python/setup.cfg | 1 + > 2 files changed, 9 insertions(+), 1 deletion(-) > > diff --git a/python/qemu/machine/machine.py > b/python/qemu/machine/machine.py > index a7081b1845..51b6e79a13 100644 > --- a/python/qemu/machine/machine.py > +++ b/python/qemu/machine/machine.py > @@ -19,6 +19,7 @@ > > import errno > from itertools import chain > +import locale > import logging > import os > import shutil > @@ -290,8 +291,14 @@ def get_pid(self) -> Optional[int]: > return self._subp.pid > > def _load_io_log(self) -> None: > + # Assume that the output encoding of QEMU's terminal output > + # is defined by our locale. If indeterminate, use a platform > default. > + _, encoding = locale.getlocale() > + if encoding is None: > + encoding = locale.getpreferredencoding(do_setlocale=False) > if self._qemu_log_path is not None: > - with open(self._qemu_log_path, "r") as iolog: > + with open(self._qemu_log_path, "r", > + encoding=encoding) as iolog: > self._iolog = iolog.read() > > @property > diff --git a/python/setup.cfg b/python/setup.cfg > index 83909c1c97..0f0cab098f 100644 > --- a/python/setup.cfg > +++ b/python/setup.cfg > @@ -104,6 +104,7 @@ good-names=i, > [pylint.similarities] > # Ignore imports when computing similarities. > ignore-imports=yes > +ignore-signatures=yes > > # Minimum lines number of a similarity. > # TODO: Remove after we opt in to Pylint 2.8.3. See commit msg. > -- > 2.30.2 > > <div dir="ltr"><div>Hi, I sent a PR for this (and an additional fix that is needed as of yesterday):</div><div><br></div><div><a href="https://lists.gnu.org/archive/html/qemu-devel/2021-09/msg04477.html">https://lists.gnu.org/archive/html/qemu-devel/2021-09/msg04477.html</a></div><div><br></div><div>Please drop this patch and prefer that series.</div><div><br></div><div>--js<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 17, 2021 at 12:23 PM Alex Bennée <<a href="mailto:alex.bennee@linaro.org">alex.bennee@linaro.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: John Snow <<a href="mailto:jsnow@redhat.com" target="_blank">jsnow@redhat.com</a>><br> <br> A few new annoyances. Of note is the new warning for an unspecified<br> encoding when opening a text file, which actually does indicate a<br> potentially real problem; see<br> <a href="https://www.python.org/dev/peps/pep-0597/#motivation" rel="noreferrer" target="_blank">https://www.python.org/dev/peps/pep-0597/#motivation</a><br> <br> Use LC_CTYPE to determine an encoding to use for interpreting QEMU's<br> terminal output. Note that Python states: "language code and encoding<br> may be None if their values cannot be determined" -- use a platform<br> default as a backup.<br> <br> Signed-off-by: John Snow <<a href="mailto:jsnow@redhat.com" target="_blank">jsnow@redhat.com</a>><br> Message-Id: <<a href="mailto:20210916040955.628560-2-jsnow@redhat.com" target="_blank">20210916040955.628560-2-jsnow@redhat.com</a>><br> Reviewed-by: Alex Bennée <<a href="mailto:alex.bennee@linaro.org" target="_blank">alex.bennee@linaro.org</a>><br> Tested-by: Alex Bennée <<a href="mailto:alex.bennee@linaro.org" target="_blank">alex.bennee@linaro.org</a>><br> Signed-off-by: Alex Bennée <<a href="mailto:alex.bennee@linaro.org" target="_blank">alex.bennee@linaro.org</a>><br> ---<br> python/qemu/machine/machine.py | 9 ++++++++-<br> python/setup.cfg | 1 +<br> 2 files changed, 9 insertions(+), 1 deletion(-)<br> <br> diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py<br> index a7081b1845..51b6e79a13 100644<br> --- a/python/qemu/machine/machine.py<br> +++ b/python/qemu/machine/machine.py<br> @@ -19,6 +19,7 @@<br> <br> import errno<br> from itertools import chain<br> +import locale<br> import logging<br> import os<br> import shutil<br> @@ -290,8 +291,14 @@ def get_pid(self) -> Optional[int]:<br> return self._subp.pid<br> <br> def _load_io_log(self) -> None:<br> + # Assume that the output encoding of QEMU's terminal output<br> + # is defined by our locale. If indeterminate, use a platform default.<br> + _, encoding = locale.getlocale()<br> + if encoding is None:<br> + encoding = locale.getpreferredencoding(do_setlocale=False)<br> if self._qemu_log_path is not None:<br> - with open(self._qemu_log_path, "r") as iolog:<br> + with open(self._qemu_log_path, "r",<br> + encoding=encoding) as iolog:<br> self._iolog = iolog.read()<br> <br> @property<br> diff --git a/python/setup.cfg b/python/setup.cfg<br> index 83909c1c97..0f0cab098f 100644<br> --- a/python/setup.cfg<br> +++ b/python/setup.cfg<br> @@ -104,6 +104,7 @@ good-names=i,<br> [pylint.similarities]<br> # Ignore imports when computing similarities.<br> ignore-imports=yes<br> +ignore-signatures=yes<br> <br> # Minimum lines number of a similarity.<br> # TODO: Remove after we opt in to Pylint 2.8.3. See commit msg.<br> -- <br> 2.30.2<br> <br> </blockquote></div></div>
diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index a7081b1845..51b6e79a13 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -19,6 +19,7 @@ import errno from itertools import chain +import locale import logging import os import shutil @@ -290,8 +291,14 @@ def get_pid(self) -> Optional[int]: return self._subp.pid def _load_io_log(self) -> None: + # Assume that the output encoding of QEMU's terminal output + # is defined by our locale. If indeterminate, use a platform default. + _, encoding = locale.getlocale() + if encoding is None: + encoding = locale.getpreferredencoding(do_setlocale=False) if self._qemu_log_path is not None: - with open(self._qemu_log_path, "r") as iolog: + with open(self._qemu_log_path, "r", + encoding=encoding) as iolog: self._iolog = iolog.read() @property diff --git a/python/setup.cfg b/python/setup.cfg index 83909c1c97..0f0cab098f 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -104,6 +104,7 @@ good-names=i, [pylint.similarities] # Ignore imports when computing similarities. ignore-imports=yes +ignore-signatures=yes # Minimum lines number of a similarity. # TODO: Remove after we opt in to Pylint 2.8.3. See commit msg.