[MERGE][#139318] bzr send @ win32: ensure that command line to invoking Thunderbird is 8-bit string, not unicode (because subprocess does not understand non-ascii unicode)

Aaron Bentley aaron at aaronbentley.com
Tue Feb 26 14:24:40 GMT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Alexander Belchenko wrote:
> Aaron Bentley пишет:
>> Alexander Belchenko wrote:
>>> This patch fixes problem with UnicodeEncodeError and subprocess module @
>>> win32.
>>
>> According to my tests, both the encoded and unicode forms are allowed on
>> Linux.  So we can encode on all platforms, which should give your change
>> better test coverage.
> 
> Hm, I use encode(xx, 'replace') that will turn any character out of current
> user encoding to '?'. If Linux accepts unicode in command-line, I think
> it's
> better to not encode on Linux and therefore preserve actual subject line.

Linux doesn't *actually* support unicode for this.  The POSIX interfaces
are byte-oriented.  What happens is that on Linux, Python converts the
unicode into byte strings where possible.  But where not possible...

$ LC_ALL=C python
Python 2.5.1 (r251:54863, Oct  5 2007, 13:36:32)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.call(['cat', u'\u1234'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/subprocess.py", line 443, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.5/subprocess.py", line 593, in __init__
    errread, errwrite)
  File "/usr/lib/python2.5/subprocess.py", line 1135, in _execute_child
    raise child_exception
TypeError: execv() arg 2 must contain only strings
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHxCEo0F+nu1YWqI0RAoufAJ91FBLDB5iNlshUXbUb1uLxt6OQogCfdmXB
v2aK660rghEHb8q6k0b/tqU=
=k7oV
-----END PGP SIGNATURE-----



More information about the bazaar mailing list