-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
Use stream encoding instead of locale preferred encoding #88
Conversation
better_exceptions/color.py
Outdated
|
||
|
||
STREAM = sys.stderr | ||
ENCODING = getattr(STREAM, "encoding", None) or "ascii" |
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.
Better to default to utf-8 IMO.
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.
@Qix- Yeah, I think you are right, that would avoid possible UnicodeEncodeError
.
@Qix- There is definitely overlap between #88 and #69, but #69 tried to go further by removing a bunch of hacky functions used for Python 2 compatibility with |
Sounds good :) |
PEP597 Encoding Warnings gives warnings about locale preferred encoding if you have the warnings enabled. What needs to happen to get this PR merged? |
Just a rebase on top of current master. I'm out of the country at the moment so my capacity for code changes is low. If @Delgan does a rebase or if you submit a new PR that is rebased I'll accept it, though it'll be a little bit before I can do a release. |
Hey there. :) I just rebased the PR. 👍 |
It's going to be a little bit before I can push a release, sorry in advance. @Delgan if you're interested in being added as a pypi maintainer just let me know what your pypi username is. |
@Qix- Thank you for your trust, but I honestly prefer not to handle the administrative part. Let me know if you need help with other developments, though. I would be happy to contribute. 👍 |
Hi.
This is intended to fix #53, finally. :)
As discussed, I replaced
locale.getpreferredencoding()
withSTREAM.encoding
. Just in case, I added a fallback toascii
ifSTREAM
has no or invalidencoding
attribute. For the tests, the encoding can be configured with thePYTHONIOENCODING
environment variable in place ofLANG
andLC_ALL
. Also, I had to removeencoding.py
and include it directly intocolor.py
to avoid circular dependency.Hopefully, this should solve reported encoding issues. ;)