Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue25411

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:SMTPHandler in the logging module fails with unicode strings
Type:Stage:resolved
Components:Versions:Python 3.6, Python 3.4, Python 3.5
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: python-dev, r.david.murray, simon04, vinay.sajip
Priority:normalKeywords:patch

Created on2015-10-15 13:02 bysimon04, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
SMTPHandler-unicode-v1.patchsimon04,2015-10-15 13:02review
Messages (4)
msg253043 -(view)Author: Simon04 (simon04)*Date: 2015-10-15 13:02
This relates to the unresolvedissue9208 (Python 2).SMTPHandler fails when receiving unicode strings.Example (frommsg109621):import logging,logging.handlerssmtpHandler = logging.handlers.SMTPHandler(    mailhost=("smtp.free.fr",25),    fromaddr="from@free.fr", toaddrs="to@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 inmsg252928 andmsg252931, EmailMessage/send_message should be used instead to resolve this issue.Patch attached.
msg253045 -(view)Author: R. David Murray (r.david.murray)*(Python committer)Date: 2015-10-15 13:51
This mostly looks good to me, Vinay.Simon: did you intentionally omit the date header, and if so why?  (The smtp server normally adds one, but you can't really depend on that).  Adding it would look like:  msg['Date'] = email.utils.localtime()(Hmm.  I wonder if send_message should add Date header if there isn't one...)
msg253127 -(view)Author: Simon04 (simon04)*Date: 2015-10-17 13:06
I omitted the date header w/o intent. Basically because I couldn't quickly figure out how to set it.
msg253131 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2015-10-17 15:24
New changeseteb843115e052 by Vinay Sajip in branch '3.4':Closes#25411: Improved Unicode support in SMTPHandler.https://hg.python.org/cpython/rev/eb843115e052New changesetb99b3ddd0ac4 by Vinay Sajip in branch '3.5':Closes#25411: Merged fix from 3.4.https://hg.python.org/cpython/rev/b99b3ddd0ac4New changeset522b5cdffd42 by Vinay Sajip in branch 'default':Closes#25411: Merged fix from 3.5.https://hg.python.org/cpython/rev/522b5cdffd42
History
DateUserActionArgs
2022-04-11 14:58:22adminsetgithub: 69597
2015-10-17 15:24:37python-devsetstatus: open -> closed

nosy: +python-dev
messages: +msg253131

resolution: fixed
stage: resolved
2015-10-17 13:06:25simon04setmessages: +msg253127
2015-10-15 13:51:45r.david.murraysetnosy: +vinay.sajip
messages: +msg253045
2015-10-15 13:21:54simon04setnosy: +r.david.murray
2015-10-15 13:02:06simon04create
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp