On Mon, 29 Nov 2010 21:26:23 -0800, Dan Stromberg wrote:

> Does anyone know what I need to do to read filenames from stdin with
> Python 3.1 and subsequently open them, when some of those filenames
> include characters with their high bit set?

Use "bytes" rather than "str". Everywhere. This means reading names from
sys.stdin.buffer (which is a binary stream) rather than sys.stdin (which
is a text stream). If you pass a "bytes" to an I/O function (e.g. open()),
it will just pass the bytes directly to the OS without any decoding.

But really, if you're writing *nix system utilities, you should probably
stick with Python 2.x until the end of time. Using 3.x will just make life
difficult for no good reason (e.g. in 3.x, os.environ also contains
Unicode strings).

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to