Narazil jsem na zajímavé chování os.listdir, pokud máte v souborech diakritiku. Co myslíte, je to chyba, není to chyba? Minimálně by to mělo být uvedeno v dokumentaci!
Je-li na Linuxu kódování utf-8, chyba se projevila pouze v běhu scriptu přes CGI? (tak na to přišel kolega který pracoval na Fedoře s utf-8), pokud ne projeví se to vždy. Ve 2.5 nevím jak se to chová? os.listdir Python documentace Changed in version 2.3: On Windows NT/2k/XP and Unix, if path is a Unicode object, the result will be a list of Unicode objects.. http://kofoto.rosdahl.net/trac/wiki/UnicodeInPython os.listdir(u"path") returns Unicode strings for names that can be decoded with sys.getfilesystemencoding() but silently returns byte strings for names that can't be decoded. That is, the return value of os.listdir(u"path") is potentially a mixed list of Unicode and byte strings. Python/2.4.2 (WXP) >>> import os, sys >>> sys.getfilesystemencoding() 'mbcs' >>> os.listdir(u'path') ['aaa.txt', 'bbb.txt', '\xe8e\x9atina.txt', 'ccc.txt'] >>> os.listdir(u'path') [u'aaa.txt', u'bbb.txt', u'\u010de\u0161tina.txt', u'ccc.txt'] >>> ...OK 3. je unicode Python/2.4.4 (Debian) >>> import os, sys >>> sys.getfilesystemencoding() 'ANSI_X3.4-1968' >>> os.listdir('path') ['aaa.txt', 'bbb.txt', '\xe8e\xb9tina.txt', 'ccc.txt'] >>> os.listdir(u'path') [u'aaa.txt', u'bbb.txt', '\xe8e\xb9tina.txt', u'ccc.txt'] >>> ...? 3. není unicode _______________________________________________ Python mailing list [email protected] http://www.py.cz/mailman/listinfo/python
