Opened 9 years ago

Closed 9 years ago

#11354 closed defect (duplicate)

UnicodeEncodeError on wiki and ticket notifications containing non-ascii codes

Reported by: anonymous Owned by: Steffen Hoffmann
Priority: normal Component: AnnouncerPlugin
Severity: normal Keywords:
Cc: nebojsa@… Trac Release: 1.0


If I choose diff for wiki pages, and if there is a non ascii in the diff itself, exception is thrown, visible only in trac log:

    self._do_send(transport, event, k, v, fmtdict[k])
  File "build/bdist.linux-armv5tel/egg/announcer/distributors/", line 481, in _do_send
    msgText = MIMEText(alternate_output, alt_msg_format)
  File "/usr/lib/python2.7/email/mime/", line 30, in __init__
    self.set_payload(_text, _charset)
  File "/usr/lib/python2.7/email/", line 226, in set_payload
  File "/usr/lib/python2.7/email/", line 262, in set_charset
    self._payload = self._payload.encode(charset.output_charset)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0161' in position 259: ordinal not in range(128)

I have traced problem down to announcer/distributors/ Following patch fixes problem for me:

Index: announcer/distributors/
--- announcer/distributors/      (revision 13419)
+++ announcer/distributors/      (working copy)
@@ -478,16 +478,16 @@
             alt_msg_format = 'html' in alternate_style and 'html' or 'plain'
-            msgText = MIMEText(alternate_output, alt_msg_format)
-            msgText.set_charset(self._charset)
+            msgText = MIMEText(alternate_output, alt_msg_format, "utf-8")
+            # msgText.set_charset(self._charset)
             parentMessage = rootMessage
         msg_format = 'html' in format and 'html' or 'plain'
-        msgText = MIMEText(output, msg_format)
-        del msgText['Content-Transfer-Encoding']
-        msgText.set_charset(self._charset)
+        msgText = MIMEText(output, msg_format, "utf-8")
+        # del msgText['Content-Transfer-Encoding']
+        # msgText.set_charset(self._charset)
         # According to RFC 2046, the last part of a multipart message is best
         #   and preferred.

I am running python 2.7.5

Attachments (0)

Change History (2)

comment:1 Changed 9 years ago by nebojsa@…

Cc: nebojsa@… added; anonymous removed

comment:2 Changed 9 years ago by Jun Omae

Resolution: duplicate
Status: newclosed

A duplicate of #10974.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Steffen Hoffmann.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.