[issue9167] argv double encoding on OSX

Ronald Oussoren report at bugs.python.org
Fri Jul 23 17:01:25 CEST 2010


Ronald Oussoren <ronaldoussoren at mac.com> added the comment:

Daniele: never mind, you already said you are on OSX 10.4.

The current behavior is only a problem when the system default encoding as implied by LANG is different from the fileystem encoding.

How to fix this is an entirely different question: most (all?) unix tools just work with byte-strings and pass those through unmodified, this means that with something like:

   subprocess.Popen(['ls', snowman])

The snowman character should be encoded using the filesystem encoding, as that is the bytestring that the C APIs that ls calls expect.

Note that encoding using the preferred encoding would result in an exception, as the snowman character cannot be encoded in ASCII or even latin1.

A possible workaround is to use the CFStringGetSystemEncoding from CoreFoundation to get the system encoding when LANG=C (and probably guarded by to be activate only on OSX releases before 10.5).

Another workaround: upgrade from OSX 10.4 to at least OSX 10.5 ;-)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9167>
_______________________________________


More information about the Python-bugs-list mailing list