[Python-Dev] Adding the 'path' module (was Re: Some RFE for review) (original) (raw)
Thomas Heller theller at python.net
Thu Jul 7 11:54:55 CEST 2005
- Previous message: [Python-Dev] Adding the 'path' module (was Re: Some RFE for review)
- Next message: [Python-Dev] Adding the 'path' module (was Re: Some RFE for review)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Neil Hodgson <nyamatongwe at gmail.com> writes:
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!
I'm sorry but that's not my opinion.
Code that can't deal with unicode entries is broken, imo. The programmer does not know where the user runs this code at what he throws at it. I think that this will hide bugs.
When I installed the first game written in Python with pygame on my daughter's PC it didn't run, simply because there was a font listed in the registry which contained umlauts somewhere.
OTOH, I once had a bug report from a py2exe user who complained that the program didn't start when installed in a path with japanese characters on it. I tried this out, the bug existed (and still exists), but I was astonished how many programs behaved the same: On a PC with english language settings, you cannot start WinZip or Acrobat Reader (to give just some examples) on a .zip or .pdf file contained in such a directory.
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.
Thomas
- Previous message: [Python-Dev] Adding the 'path' module (was Re: Some RFE for review)
- Next message: [Python-Dev] Adding the 'path' module (was Re: Some RFE for review)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]