Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] gconsole fails on long output with multibyte chars #2720

Open
marisn opened this issue Dec 29, 2022 · 0 comments
Open

[Bug] gconsole fails on long output with multibyte chars #2720

marisn opened this issue Dec 29, 2022 · 0 comments
Labels
bug Something isn't working GUI wxGUI related Python Related code is in Python

Comments

@marisn
Copy link
Contributor

marisn commented Dec 29, 2022

While working on a new module I printed a lot of data to stdout. When run from CLI, it was working fine, when run from GUI, it crashes all the time:

Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "dist.x86_64-pc-linux-gnu/gui/wxpython/core/gconsole.py", line 171, in run
    self.resultQ.put((requestId, self.requestCmd.run()))
  File "dist.x86_64-pc-linux-gnu/gui/wxpython/core/gcmd.py", line 601, in run
    self._redirect_stream()
  File "dist.x86_64-pc-linux-gnu/gui/wxpython/core/gcmd.py", line 626, in _redirect_stream
    line = recv_some(self.module, e=0, stderr=0)
  File "dist.x86_64-pc-linux-gnu/gui/wxpython/core/gcmd.py", line 325, in recv_some
    y.append(decode(r))
  File "dist.x86_64-pc-linux-gnu/etc/python/grass/script/utils.py", line 201, in decode
    return bytes_.decode(enc)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc5 in position 4095: unexpected end of data

Version is a ~week old main branch.

The cause is reading module output in chunks and passing chunks to decode call. This will work fine as long as last byte of chunk is not a part of multibyte character. In such case decoder will throw an error (as in this bug report). The code dealing with module output should be replaced with a stream reader that handles multibyte chars in a proper way.

@marisn marisn added the bug Something isn't working label Dec 29, 2022
marisn added a commit to marisn/grass that referenced this issue Dec 29, 2022
@marisn marisn added GUI wxGUI related Python Related code is in Python labels Dec 29, 2022
marisn added a commit that referenced this issue Feb 13, 2023
* A test case for bug #2720 (do not split multibyte chars when parsing input)
ninsbl pushed a commit to ninsbl/grass that referenced this issue Feb 17, 2023
* A test case for bug OSGeo#2720 (do not split multibyte chars when parsing input)
neteler pushed a commit to nilason/grass that referenced this issue Nov 7, 2023
* A test case for bug OSGeo#2720 (do not split multibyte chars when parsing input)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working GUI wxGUI related Python Related code is in Python
Projects
None yet
Development

No branches or pull requests

1 participant