Modify ↓
#11227 closed defect (duplicate)
UnicodeEncodeError with accented characters
Reported by: | Stephan Geulette | Owned by: | Steffen Hoffmann |
---|---|---|---|
Priority: | normal | Component: | AnnouncerPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 1.0 |
Description (last modified by )
trac 1.0.1, python 2.7.3
traceback
Traceback (most recent call last): File "build/bdist.linux-x86_64/egg/announcer/api.py", line 584, in _real_send evt) File "build/bdist.linux-x86_64/egg/announcer/distributors/mail.py", line 330, in distribute self._do_send(transport, event, k, v, fmtdict[k]) File "build/bdist.linux-x86_64/egg/announcer/distributors/mail.py", line 488, in _do_send msgText = MIMEText(output, msg_format) File "/srv/python/python273/lib/python2.7/email/mime/text.py", line 30, in __init__ self.set_payload(_text, _charset) File "/srv/python/python273/lib/python2.7/email/message.py", line 226, in set_payload self.set_charset(charset) File "/srv/python/python273/lib/python2.7/email/message.py", line 262, in set_charset self._payload = self._payload.encode(charset.output_charset) UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 12: ordinal not in range(128)
output contains :
u"#6373: ne cr\xe9er des utilisateurs qu'en mode developpement\nNOUVEAU Am\xe9lioration\n---------------------------------------------------------------------\nReporter: sgeulette\nOwner: (None)\nPriority: Normale\nMilestone: Project 0.1 PST Prototype\nSeverity: Non bloquant\n\n---------------------------------------------------------------------\nComment (by sgeulette):\n\ntest5\n--\nTicket URL: <URL:http://trac.imio.be/trac/ticket/6373>\nIMIO <URL:http://www.imio.be>\nIntercommunale de Mutualisation Informatique et Organisationnelle\n"
The charset is not passed to MIMEText in msgText = MIMEText(output, msg_format)
With MIMEText(output, msg_format, _charset=self._charset.output_charset)
, it's ok
Attachments (0)
Change History (5)
comment:1 Changed 11 years ago by
Description: | modified (diff) |
---|
comment:2 Changed 11 years ago by
comment:3 Changed 11 years ago by
when passing charset to MIMEText, in my case the cte is set to base64
It works if the cte already in msgText isn't modified ! # del msgTextContent-Transfer-Encoding? # msgText.set_charset(self._charset)
comment:5 Changed 11 years ago by
Resolution: | fixed → duplicate |
---|
Note: See
TracTickets for help on using
tickets.
Beware, the proposed correction doesn't work !