[Python-Dev] Proposal: new environment variable PYTHONSTDOUTENCODING

"Martin v. Löwis" martin at v.loewis.de
Tue May 20 10:22:37 CEST 2008


I'd like to propose a new environment variable PYTHONSTDOUTENCODING.
This is meant to solve various problems that people had with Python
not detecting their terminal encoding correctly; it would override
any detection that Python would use for determining the encoding of
stdout (and stdin - but that's less relevant in 2.x).

In particular, setting this environment variable would also disable
the detection of whether stdout is a terminal. This is desirable
for cases as the pydev eclipse plugin, where Python currently
fails to detect that the output is a terminal (and technically,
what Eclipse provides is not a terminal, but just a pipe, as you
can't do pseudoterms in Java).

This would have the additional effect that the encoding also gets
in effect when redirecting stdout to a file. Whether or not this
is a good thing might be debatable; giving the user the control over
it (to set or clear that variable) is a good thing, IMO.

Naming contest: it probably would be the longest of the PYTHON*
variables. I would not want to call it PYTHONENCODING, or
PYTHONSTDENCODING, though, because people might infer that it
affects sys.getdefaultencoding(), which it shouldn't.

Regards,
Martin


More information about the Python-Dev mailing list