[Python-Dev] Unicode filenames

Just van Rossum just@letterror.com
Sun, 9 Feb 2003 12:59:51 +0100


MacOSX fully supports unicode filenames (utf-8 is used throughout), and
I'm tempted to set Py_FileSystemDefaultEncoding to "utf8" for OSX. Jack
pointed me to a long thread about unicode filenames that took place on
python-dev last year, but I can't deduce from it whether there are any
disadvantages of setting Py_FileSystemDefaultEncoding.

Setting it seems to work wonderful. However, I'm a bit surprised that
os.listdir() doesn't return unicode strings. Is that because it would
break too much code?

BTW. if I try to create a file with an 8-bit filename which is _not_
valid utf-8, I get a strange error:

  >>> f = open("\xff", "w")
  Traceback (most recent call last):
    File "<stdin>", line 1, in ?
  IOError: invalid mode: w
  >>> 

This exception is thrown when errno is EINVAL, which apparently can also
mean that the filename arg is bad. Not sure if we can fix this.

Just