Modify

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

Description

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/mail.py", line 481, in _do_send
    msgText = MIMEText(alternate_output, alt_msg_format)
  File "/usr/lib/python2.7/email/mime/text.py", line 30, in __init__
    self.set_payload(_text, _charset)
  File "/usr/lib/python2.7/email/message.py", line 226, in set_payload
    self.set_charset(charset)
  File "/usr/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'\u0161' in position 259: ordinal not in range(128)

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

Index: announcer/distributors/mail.py
===================================================================
--- announcer/distributors/mail.py      (revision 13419)
+++ announcer/distributors/mail.py      (working copy)
@@ -478,16 +478,16 @@
             rootMessage.attach(parentMessage)
 
             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.attach(msgText)
         else:
             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.
         parentMessage.attach(msgText)

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

Action
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'.
Author


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

 
Note: See TracTickets for help on using tickets.