[Patches] [ python-Patches-612627 ] Allow more Unicode on sys.stdout

noreply@sourceforge.net noreply@sourceforge.net
Sat, 21 Sep 2002 13:32:23 -0700


Patches item #612627, was opened at 2002-09-21 22:32
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=612627&group_id=5470

Category: Core (C code)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Martin v. Löwis (loewis)
Assigned to: Nobody/Anonymous (nobody)
Summary: Allow more Unicode on sys.stdout

Initial Comment:
This patch extends the set of Unicode strings that can
be printed to sys.stdout, to support all strings that
the terminal will likely support. It also adds an
encoding attribute to sys.std{in,out}.

To do that:
- it adds a .encoding attribute to all file objects,
which is normally None
- initializes the encoding of sys.stdin and sys.stdout
if either is a terminal.
- adds a wrapper object around sys.stdout in site.py
that encodes all Unicode objects according to the
detected encoding, if that encoding is known to Python

To find the encoding of the terminal, it
- uses GetConsoleCP and GetConsoleOutputCP on Windows,
- uses nl_langinfo(CODESET) on Unix, if available.

The primary rationale for this change is that people
should be able to print Unicode in an interactive
session. A parallel change needs to be added for IDLE,
so that it adds the .encoding attribute to the emulated
stdout (it already supports printing of Unicode on stdout).

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=612627&group_id=5470