"Martin v. Löwis" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> That's apparently a bug in os.access, which doesn't support Unicode file > names. As a work around, do > > def access(name, mode, orig=os.access): > try: > return orig(name, mode) > except UnicodeError: > return orig(name.encode(sys.getfilesystemencoding(), mode)) > os.access=access > > Apparently, access is used so rarely that nobody has noticed yet (or > didn't bother to report). os.path.isfile() builds on os.stat(), which > does support Unicode file names. > > Regards, > Martin Ah, thanks! Now another question arises: you use sys.getfilesystemencoding() to encode the file name, which looks like it's the preferred method. However when I tried to find out how this works I got a little confused again (from the library reference): getfilesystemencoding() Return the name of the encoding used to convert Unicode filenames into system file names, or None if the system default encoding is used. The result value depends on the operating system: (...) * On Unix, the encoding is the user's preference according to the result of nl_langinfo(CODESET), or None if the nl_langinfo(CODESET) failed. On my box (mandrake-10.1) sys.getfilesystemencoding() returns 'ISO-8859-15', however : >>> locale.nl_langinfo(locale.CODESET) 'ANSI_X3.4-1968' >>> Anyway, my app currently runs with python-2.2 and I would like to keep it that way if possible, so I wonder which is the preferred replacement for sys.getfilesystemencoding() on versions < 2.3 , or in particular, will the method I use to determine "sysencoding" I described in my original post be safe or are there any traps I missed (it's supposed to run on linux only)? Thanks and best regards Michael -- http://mail.python.org/mailman/listinfo/python-list