[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)
John Arbash Meinel
john at arbash-meinel.com
Wed Feb 27 15:13:51 GMT 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Alexander Belchenko wrote:
| This patch fixes problem with UnicodeEncodeError and subprocess module @
| win32.
| Actually I need this fix only for Thunderbird, default MapiClient is not
| affected
| by unicode bug. So if someone think that subject.encode(user_encdoing,
| 'replace')
| should be only in Thunderbird class, I'll move it there.
|
+ if sys.platform == 'win32':
+ user_encoding = osutils.get_user_encoding()
+ if to:
+ to = to.encode(user_encoding, 'replace')
+ if subject:
+ subject = subject.encode(user_encoding, 'replace')
~ cmdline.extend(self._get_compose_commandline(to, subject,
~ attach_path))
^- It almost seems to make more sense to put this check in
"_get_compose_commandline".
I've never really been a fan of "encode(..., 'replace')", though I guess it is
necessary here. It just means that it is lossy, which means your subject and
destination address could easily end up garbled. I suppose that is better than
not getting sent at all...
+ message_options['attachment'] = str(urlutils.local_path_to_url(
+ attach_path))
^- If local_path_to_url isn't returning a plain string, that indicates a bug in
local_path_to_url. Because URLs (for us) are defined as 7-bit strings.
So I would rather fix local_path_to_url rather than put a bandage around it.
Otherwise I don't have a problem with doing the encoding ourselves.
BB:tweak
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHxX4vJdeBCYSNAAMRAuGPAJ4vAkyM+DpsjR0UXgU+nMAldMu2IQCeJ9vB
GeqBsWDIW8p15sch/CyqpDg=
=rR8G
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list