[Libreoffice-commits] core.git: Branch 'libreoffice-4-1-0' - scripting/source
Caolán McNamara
caolanm at redhat.com
Mon Jul 15 07:30:31 PDT 2013
scripting/source/pyprov/mailmerge.py | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
New commits:
commit 6a5ba90664634b288296c4e8eebc4cd6eabe6105
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Jul 13 15:56:41 2013 +0100
Resolves: fdo#66761 Macro controlled Python Mailmerge broken
Change-Id: Id8bbf06a5571534aa5eef8624e89565fe3715938
(cherry picked from commit c4aa13c931da11164835a7aafbfd7e44bd5714ca)
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 <dtardon at redhat.com>
Tested-by: David Tardon <dtardon at redhat.com>
(cherry picked from commit c71f67198cd6fc98f77289c4f0276a45d19700d8)
Reviewed-on: https://gerrit.libreoffice.org/4915
Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
Reviewed-by: Petr Mladek <pmladek at suse.cz>
Tested-by: Petr Mladek <pmladek at suse.cz>
diff --git a/scripting/source/pyprov/mailmerge.py b/scripting/source/pyprov/mailmerge.py
index f70f034..3cfb6d3 100755
--- a/scripting/source/pyprov/mailmerge.py
+++ b/scripting/source/pyprov/mailmerge.py
@@ -181,10 +181,21 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
textmsg['Content-Type'] = mimeEncoding
textmsg['MIME-Version'] = '1.0'
- textbody = textbody.encode('utf-8')
+ try:
+ #it's a string, get it as utf-8 bytes
+ textbody = textbody.encode('utf-8')
+ except:
+ #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)
@@ -466,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:
More information about the Libreoffice-commits
mailing list