> Why only set an encoding on these streams when they're directly
> connected to a tty?

If you are sending data to the terminal, you can be fairly certain
that the locale's encoding should be used. It's a convenience feature
for the interactive mode, so that Unicode strings print correctly.

When sending data to a pipe or to a file, God knows what encoding
should have been used. If it's any XML file (for example), using the
locale's encoding would be incorrect, and the encoding declared
in the XML declaration should be used (or UTF-8 if no declaration
is included). If it's a HTTP socket, it really should be restricted
to ASCII in the headers, and then to the content-type. And so on.

So in general, the applications should arrange to the the encoding
or encode themselves when they write to some output stream. If they
fail to do so, it's a bug in the application, not in Python.

> I'll patch things to remove the isatty conditional if that's acceptable.

It will make your Python release incompatible with everybody else's,
and will probably lead to moji-bake. Otherwise, it's fine.

Regards,
Martin
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to