Modify

Opened 14 months ago

Closed 14 months ago

Last modified 14 months ago

#11227 closed defect (duplicate)

UnicodeEncodeError with accented characters

Reported by: sgeulette Owned by: hasienda
Priority: normal Component: AnnouncerPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.0

Description (last modified by jun66j5)

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 14 months ago by jun66j5

  • Description modified (diff)

comment:2 Changed 14 months ago by sgeulette

Beware, the proposed correction doesn't work !

comment:3 Changed 14 months ago by sgeulette

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:4 Changed 14 months ago by rjollos

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

comment:5 Changed 14 months ago by rjollos

  • Resolution changed from fixed to duplicate

Add Comment

Modify Ticket

Action
as 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.