Opened 9 months ago

Closed 7 months ago

#11354 closed defect (duplicate)

UnicodeEncodeError on wiki and ticket notifications containing non-ascii codes

Reported by: anonymous Owned by: hasienda
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 months ago by nebojsa@…

  • Cc nebojsa@… added

comment:2 Changed 7 months ago by jun66j5

  • Resolution set to duplicate
  • Status changed from new to closed

A duplicate of #10974.

Add Comment

Modify Ticket

as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from hasienda. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.

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

Note: See TracTickets for help on using tickets.