[Python-Dev] PEP 383: Non-decodable Bytes in System Character Interfaces
Ronald Oussoren
ronaldoussoren at mac.com
Fri May 1 07:41:16 CEST 2009
On 30 Apr, 2009, at 21:33, Piet van Oostrum wrote:
>>>>>> Ronald Oussoren <ronaldoussoren at mac.com> (RO) wrote:
>
>> RO> For what it's worth, the OSX API's seem to behave as follows:
>> RO> * If you create a file with an non-UTF8 name on a HFS+
>> filesystem the
>> RO> system automaticly encodes the name.
>
>> RO> That is, open(chr(255), 'w') will silently create a file named
>> '%FF'
>> RO> instead of the name you'd expect on a unix system.
>
> 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'
>>>>
That's odd. Which version of OSX do you use?
ronald at Rivendell-2[0]$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.5.6
BuildVersion: 9G55
[~/testdir]
ronald at Rivendell-2[0]$ /usr/bin/python
Python 2.5.1 (r251:54863, Jan 13 2009, 10:26:13)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.listdir('.')
[]
>>> open(chr(255), 'w').write('x')
>>> os.listdir('.')
['%FF']
>>>
And likewise with python 2.6.1+ (after cleaning the directory):
[~/testdir]
ronald at Rivendell-2[0]$ python2.6
Python 2.6.1+ (release26-maint:70603, Mar 26 2009, 08:38:03)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.listdir('.')
[]
>>> open(chr(255), 'w').write('x')
>>> os.listdir('.')
['%FF']
>>>
>
> I once got a tar file from a Linux system which contained a file
> with a
> non-ASCII, ISO-8859-1 encoded filename. The tar file refused to be
> unpacked on a HFS+ filesystem.
> --
> Piet van Oostrum <piet at cs.uu.nl>
> URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
> Private email: piet at vanoostrum.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2224 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-dev/attachments/20090501/1fa65538/attachment.bin>
More information about the Python-Dev
mailing list