Opened 21 months ago

Closed 21 months ago

Last modified 21 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 (most recent call last):
  File "build/bdist.linux-x86_64/egg/announcer/", line 584, in _real_send
  File "build/bdist.linux-x86_64/egg/announcer/distributors/", line 330, in distribute
    self._do_send(transport, event, k, v, fmtdict[k])
  File "build/bdist.linux-x86_64/egg/announcer/distributors/", line 488, in _do_send
    msgText = MIMEText(output, msg_format)
  File "/srv/python/python273/lib/python2.7/email/mime/", line 30, in __init__
    self.set_payload(_text, _charset)
  File "/srv/python/python273/lib/python2.7/email/", line 226, in set_payload
  File "/srv/python/python273/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'\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:>\nIMIO <URL:>\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 21 months ago by jun66j5

  • Description modified (diff)

comment:2 Changed 21 months ago by sgeulette

Beware, the proposed correction doesn't work !

comment:3 Changed 21 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 21 months ago by rjollos

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

Duplicate of #10974.

comment:5 Changed 21 months ago by rjollos

  • Resolution changed from fixed to duplicate

Add Comment

Modify Ticket

as closed The owner will remain hasienda.
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.