diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2007-08-11 14:02:14 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2007-08-11 14:02:14 (GMT) |
commit | d1cd4d41762ba55bfa121875fbcbde19fb6a35f1 (patch) | |
tree | efc776f69cdf44259a96e12ada8ea14dbe9e0362 /Lib | |
parent | 79c320898d43eaafa28c1c67a105a17cb9b233bf (diff) | |
download | cpython-d1cd4d41762ba55bfa121875fbcbde19fb6a35f1.zip cpython-d1cd4d41762ba55bfa121875fbcbde19fb6a35f1.tar.gz cpython-d1cd4d41762ba55bfa121875fbcbde19fb6a35f1.tar.bz2 |
Set sys.stdout.encoding properly.
Always set LC_CTYPE on interpreter startup.
Add device_encoding function.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/io.py | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -971,8 +971,13 @@ class TextIOWrapper(TextIOBase): if newline not in (None, "\n", "\r\n"): raise ValueError("illegal newline value: %r" % (newline,)) if encoding is None: - # XXX This is questionable - encoding = sys.getfilesystemencoding() or "latin-1" + try: + encoding = os.device_encoding(buffer.fileno()) + except AttributeError: + pass + if encoding is None: + import locale + encoding = locale.getpreferredencoding() self.buffer = buffer self._encoding = encoding |