[New-bugs-announce] [issue25411] SMTPHandler in the logging module fails with unicode strings
simon04
report at bugs.python.org
Thu Oct 15 15:02:06 CEST 2015
New submission from simon04:
This relates to the unresolved issue9208 (Python 2).
SMTPHandler fails when receiving unicode strings.
Example (from msg109621):
import logging,logging.handlers
smtpHandler = logging.handlers.SMTPHandler(
mailhost=("smtp.free.fr",25),
fromaddr="from at free.fr", toaddrs="to at free.fr",
subject=u"error message")
LOG = logging.getLogger()
LOG.addHandler(smtpHandler)
LOG.error(u"accentu\u00E9")
… fails:
--- 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: ()
As discussed in msg252928 and msg252931, EmailMessage/send_message should be used instead to resolve this issue.
Patch attached.
----------
files: SMTPHandler-unicode-v1.patch
keywords: patch
messages: 253043
nosy: simon04
priority: normal
severity: normal
status: open
title: SMTPHandler in the logging module fails with unicode strings
versions: Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file40787/SMTPHandler-unicode-v1.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25411>
_______________________________________
More information about the New-bugs-announce
mailing list