[Python-Dev] Adding the 'path' module (was Re: Some RFE for review)

Neil Hodgson nyamatongwe at gmail.com
Wed Jul 6 13:11:26 CEST 2005


Guido van Rossum:

> Ah, sigh. I didn't know that os.listdir() behaves differently when the
> argument is Unicode. Does os.listdir(".") really behave differently
> than os.listdir(u".")? 

   Yes:
>>> os.listdir(".")
['abc', '????????????']
>>> os.listdir(u".")
[u'abc', u'\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435']

> Bah! I don't think that's a very good design
> (although I see where it comes from). 

   Partly my fault. At the time I was more concerned with making
functionality possible rather than convenient.

> Promoting only those entries
> that need it seems the right solution -- user code that can't deal
> with the Unicode entries shouldn't be used around directories
> containing unicode -- if it needs to work around unicode it should be
> fixed to support that!

   OK, I'll work on a patch for that but I'd like to see the opinions
of the usual unicode guys as this will produce more opportunities for
UnicodeDecodeError. The modification will probably work in the
opposite way, asking for all the names in unicode and then attempting
to convert to the default code page with failures retaining the
unicode name.

   Neil


More information about the Python-Dev mailing list