scripting/source/pyprov/mailmerge.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
New commits: commit aab42944ad90e86ac43dedc7e11be8eb2019d833 Author: Caolán McNamara <caol...@redhat.com> Date: Sat Jul 13 21:45:29 2013 +0100 Related: fdo#66761 the double-encoding bug appears gone in python 3.3.2 i.e. I see the bug in our built-in python3 3.3.0 but not in my system python 3.3.2 and there's a raft of email related bug fixes in the 3.3.2/3.3.1 python Changelog Change-Id: I257770cd0ec41fc3b2f2a638009b075b9a2f325f (cherry picked from commit 24078e3501042e8693ef1f9d3edebbc47e37ce12) Related: fdo#66761 we want the bytes, not a str representation of them Change-Id: I3c268b0c51f7e1ddd2fa6588f40412a33f316b52 (cherry picked from commit f460556bfa6bd55df3cd4b2288524d63db284d7e) Reviewed-on: https://gerrit.libreoffice.org/4909 Reviewed-by: David Tardon <dtar...@redhat.com> Tested-by: David Tardon <dtar...@redhat.com> (cherry picked from commit c71f67198cd6fc98f77289c4f0276a45d19700d8) Reviewed-on: https://gerrit.libreoffice.org/4914 diff --git a/scripting/source/pyprov/mailmerge.py b/scripting/source/pyprov/mailmerge.py index af10dbe..3cfb6d3 100755 --- a/scripting/source/pyprov/mailmerge.py +++ b/scripting/source/pyprov/mailmerge.py @@ -182,12 +182,20 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): textmsg['MIME-Version'] = '1.0' try: + #it's a string, get it as utf-8 bytes textbody = textbody.encode('utf-8') except: - textbody = str(textbody.value).encode('utf-8') + #it's a bytesequence, get raw bytes + textbody = textbody.value if sys.version >= '3': - #http://stackoverflow.com/questions/9403265/how-do-i-use-python-3-2-email-module-to-send-unicode-messages-encoded-in-utf-8-w - textbody = textbody.decode('iso8859-1') + if sys.version_info.minor < 3 or (sys.version_info.minor == 3 and sys.version_info.micro <= 1): + #http://stackoverflow.com/questions/9403265/how-do-i-use-python-3-2-email-module-to-send-unicode-messages-encoded-in-utf-8-w + #see http://bugs.python.org/16564, etc. basically it now *seems* to be all ok + #in python 3.3.2 onwards, but a little busted in 3.3.0 + + textbody = textbody.decode('iso8859-1') + else: + textbody = textbody.decode('utf-8') c = Charset('utf-8') c.body_encoding = QP textmsg.set_payload(textbody, c) @@ -469,15 +477,15 @@ class PyMailMessage(unohelper.Base, XMailMessage): self.bccrecipients.append(bccrecipient) def getRecipients( self ): if dbg: - print("PyMailMessage.getRecipients: " + self.recipients, file=dbgout) + print("PyMailMessage.getRecipients: " + str(self.recipients), file=dbgout) return tuple(self.recipients) def getCcRecipients( self ): if dbg: - print("PyMailMessage.getCcRecipients: " + self.ccrecipients, file=dbgout) + print("PyMailMessage.getCcRecipients: " + str(self.ccrecipients), file=dbgout) return tuple(self.ccrecipients) def getBccRecipients( self ): if dbg: - print("PyMailMessage.getBccRecipients: " + self.bccrecipients, file=dbgout) + print("PyMailMessage.getBccRecipients: " + str(self.bccrecipients), file=dbgout) return tuple(self.bccrecipients) def addAttachment( self, aMailAttachment ): if dbg:
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits