simon04 added the comment:

I don't see why/how this should be fixed in Python 3.

Using the example from msg109621 and Python 3.5.0, I get:
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.5/logging/handlers.py", line 985, in emit
    smtp.sendmail(self.fromaddr, self.toaddrs, msg)
  File "/usr/lib/python3.5/smtplib.py", line 846, in sendmail
    msg = _fix_eols(msg).encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 
108: ordinal not in range(128)
Call stack:
  File "/tmp/x.py", line 8, in <module>
    LOG.error(u"accentu\u00E9")
Message: 'accentué'
Arguments: ()

The problem is that an SMTP message is constructed and non-ASCII characters are 
not escaped in SMTPHandler.emit. A robust fix would be to use 
email.mime.text.MIMEText instead:

msg = MIMEText(msg)
msg['Subject'] = self.getSubject(record)
msg['From'] = self.fromaddr
msg['To'] = ",".join(self.toaddrs)

----------
nosy: +simon04

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9208>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to