mirror of
https://github.com/hakril/PythonForWindows
synced 2026-06-08 14:31:45 +00:00
Improve pycompat when stdout is not a tty (no stdout.encoding)
This commit is contained in:
+4
-1
@@ -1,4 +1,5 @@
|
||||
import sys
|
||||
import locale
|
||||
|
||||
is_py3 = (sys.version_info.major >= 3)
|
||||
|
||||
@@ -47,7 +48,9 @@ else: # py2.7
|
||||
# No unicode for now on py2
|
||||
return s
|
||||
|
||||
repr_encoding = sys.stdout.encoding
|
||||
# sys.stdout.encoding may be None if not a tty
|
||||
# Use sys.stdout.isatty() ?
|
||||
repr_encoding = sys.stdout.encoding or locale.getpreferredencoding()
|
||||
|
||||
def urepr_encode(ustr):
|
||||
# assert isinstance(s, unicode) # Make the check explicitly ?
|
||||
|
||||
Reference in New Issue
Block a user