[Python-Dev] PEP 383: Non-decodable Bytes in System Character Interfaces

Toshio Kuratomi a.badger at gmail.com
Thu Apr 30 23:35:42 CEST 2009

Thomas Breuel wrote:
>     Not for me (I am using Python 2.6.2).
>     >>> f = open(chr(255), 'w')
>     Traceback (most recent call last):
>      File "<stdin>", line 1, in <module>
>     IOError: [Errno 22] invalid mode ('w') or filename: '\xff'
>     >>>
> You can get the same error on Linux:
> $ python
> Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
> [GCC 4.3.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> f=open(chr(255),'w')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> IOError: [Errno 22] invalid mode ('w') or filename: '\xff'
> (Some file system drivers do not enforce valid utf8 yet, but I suspect
> they will in the future.)
Do you suspect that from discussing the issue with kernel developers or
reading a thread on lkml?  If not, then you're suspicion seems to be
pretty groundless....

The fact that VFAT enforces an encoding does not lend itself to your
argument for two reasons:

1) VFAT is not a Unix filesystem.  It's a filesystem that's compatible
with Windows/DOS.  If Windows and DOS have filesystem encodings, then it
makes sense for that driver to enforce that as well.  Filesystems
intended to be used natively on Linux/Unix do not necessarily make this
design decision.

2) The encoding is specified when mounting the filesystem.  This means
that you can still mix encodings in a number of ways.  If you mount with
an encoding that has full byte coverage, for instance, each user can put
filenames from different encodings on there.  If you mount with utf8 on
a system which uses euc-jp as the default encoding, you can have full
paths that contain a mix of utf-8 and euc-jp.  Etc.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-dev/attachments/20090430/e26f76b4/attachment.pgp>

More information about the Python-Dev mailing list