-
Notifications
You must be signed in to change notification settings - Fork 68
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: use errors=replace for stdout #536
Conversation
4c18fd6
to
cd9b174
Compare
Unfortunately the added test catches the issue reported in #535 only when run without pytest stdout capture (namely with the |
cd9b174
to
0ed8812
Compare
I can confirm that this PR fixes my issue. Instead of an error and build fail now, I get question mark symbols ( |
Thanks for testing. We can choose other alternative representations for characters that cannot be represented in the current encoding. I went for the |
IMHO the |
+1 from me, seems like a good choice. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks @dnicolodi. This looks fine to merge as is, and quite nice that we can drop a dependency. Just one question about the one difference with the corresponding code in Meson for color handling.
mesonpy/_util.py
Outdated
if not kernel.GetConsoleMode(stdout, byref(mode)): | ||
return False | ||
|
||
return bool(kernel.SetConsoleMode(stdout, mode.value | ENABLE_VIRTUAL_TERMINAL_PROCESSING)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The one difference with mesonbuild/mlog.py
is that that adds or os.environ.get('ANSICON')
(see https://github.com/adoxa/ansicon/blob/37f92009f6ca4938a34a1d7cecff41d331c7423c/readme.txt#L119 for the docs of that env var). It's not clear to me that that case is covered by the checks before calling setup_windows_console
here - should it be added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be handled indeed. I had the impression that ansicon was some legacy thing, but I checked and the ANSICON
environment variable is used by other terminal emulators on Windows. I'll add checking for the environment variable.
We print log messages and error messages that may contain file names containing characters that cannot be represented in the stdout encoding. Use replacement markers for those instead than raising UnicodeEncodeError. Fixes mesonbuild#535.
0ed8812
to
45e792d
Compare
I'm moving dropping the colorama dependency to another PR and merging this one. |
No description provided.