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

Unicode characters not rendering correctly #6136

Closed
willmcgugan opened this issue May 22, 2020 · 6 comments
Closed

Unicode characters not rendering correctly #6136

willmcgugan opened this issue May 22, 2020 · 6 comments
Labels
Needs-Tag-Fix Doesn't match tag requirements Resolution-External For issues that are outside this codebase

Comments

@willmcgugan
Copy link

Environment

Microsoft Windows [Version 10.0.18363.720]
Terminal v1.0.1401.0

(It's a VM if that makes a difference)

Steps to reproduce

Install Rich python library (https://github.com/willmcgugan/rich), and run the following:

python -m rich.color

Expected behavior

Unicode box characters should render normally. The same output works with OSX / Linux.

Actual behavior

You should see broken unicode characters in the middle of the tables. Here are some examples:

Screen Shot 2020-05-22 at 14 38 00

Screen Shot 2020-05-22 at 14 38 25

If I was to hazard a guess I'd say that the utf-8 has been split over some internal buffer, and a multi-byte character was truncated at the boundary.

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels May 22, 2020
@skyline75489
Copy link
Collaborator

This feels like a dup of #714 and/or #455

@DHowett
Copy link
Member

DHowett commented Jun 5, 2020

This feels more like... hmm

We've got a bunch of validation that Terminal and Console properly buffer UTF-8 when it comes in.

This sound suspiciously like #386, which ended up being a CMD issue.

Is this a Python issue? I found PEP-0528, which discusses getting UTF-8 out of Python onto the console.

Of note: if you run it under WSL, it is beautiful. Same library, same terminal, different cpython runtime. 😄

@DHowett DHowett added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jun 5, 2020
@willmcgugan
Copy link
Author

Very curious.

I've discovered that if I write the output to a file rather than to the terminal, and the use the type command to write the file to the terminal, the issue is no longer present.

But if I then open the same file in Python and write it to stdout, the issue appears. But only if I do the write in a single chunk. If I write in smaller chunks then it's fine.

I tried this on Python 3.8.1, 3.8.3, 3.9.0a6 and all had the same problem.

So it's clearly related to Python, but quite where the fault lies I'm not sure!

Let me know if there is anything I can do to help you diagnose. I could send you the output from the color table if that helps.

@ghost ghost added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Jun 6, 2020
@DHowett
Copy link
Member

DHowett commented Jun 26, 2020

So, I'm also unsure of how to proceed. I think the best way forward would be a bug filed on cpython (bugs.python.org). I'm concerned about their buffering, given your remark about doing the write in a single chunk. 😄

There's a bit of stuff here-
https://github.com/python/cpython/blob/578c3955e0222ec7b3146197467fbb0fcfae12fe/Modules/_io/winconsoleio.c#L979-L988
-that might be of interest. This is the only place they call WriteConsoleW.

I'm gonna close this one out as, perhaps, something we don't have too much control over.

@DHowett
Copy link
Member

DHowett commented Jun 26, 2020

BINGO!

/dup https://bugs.python.org/issue37871

@ghost
Copy link

ghost commented Jun 26, 2020

Hi! We've identified this issue as a duplicate of one that exists on somebody else's Issue Tracker. Please make sure you subscribe to the referenced external issue for future updates. Thanks for your report!

@ghost ghost closed this as completed Jun 26, 2020
@ghost ghost added Resolution-External For issues that are outside this codebase and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Attention The core contributors need to come back around and look at this ASAP. labels Jun 26, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Tag-Fix Doesn't match tag requirements Resolution-External For issues that are outside this codebase
Projects
None yet
Development

No branches or pull requests

3 participants