Open throwable-one opened 6 years ago
Could be fixed by removing check_encoding as suggested here https://github.com/Drekin/win-unicode-console/issues/36
Does the solution of #36 work for you? Also thank you for the pull request, but I'll probably add something like
no_encoding = object()
stdin_encoding = getattr(sys.stdin, "encoding", no_encoding)
if stdin_encoding is no_encoding: warn()
So, stdin
and stdout
cases are distinguished. Also, there is probably a reason to use stacklevel=3 in the warn, so I would use it here also.
Note that I have also had an issue with this problem when using py2exe on code that uses this module. (It has a Blackhole class that substitutes for sys.stdout and doesn't have an encoding property) In my case I found that getattr(sys.stdout, "encoding", None) worked fine.
@GadgetSteve Is a warning ok for you?
@Drekin A clear warning is always better than a crash.
According to Python manual
sys.stdout
should haveencoding
. Unfortunatelly,nose
monekypatches it withStringIO
with out of encoding.See: https://github.com/nose-devs/nose/issues/1065
Its nose fault, not win-unicode-console fault. But can we please do
?