Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue32680

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:smtplib SMTP instances missing a default sock attribute
Type:Stage:resolved
Components:Versions:Python 3.8
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: Romuald, amirjn, giampaolo.rodola, matrixise
Priority:normalKeywords:patch

Created on2018-01-26 15:26 byRomuald, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Pull Requests
URLStatusLinkedEdit
PR 5345mergedRomuald,2018-01-26 15:31
Messages (7)
msg310764 -(view)Author: Romuald Brunet (Romuald)*Date: 2018-01-26 15:26
SMTP instances from the smtplib module are not creating their sock attribute consistently after __init__When host is sent as parameter a sock object is created (and hopefully, connected)When the host is not sent, the sock attribute doesn't exist at all
msg310766 -(view)Author: Romuald Brunet (Romuald)*Date: 2018-01-26 15:34
My use case:try:  s = SMTP('myhost')  s.do_some_sending()finaly:  if s is not None and s.sock is not None:    s.quit()But I realize just now that in that case, if s was initialized correctly, its sock was inevitably set
msg310774 -(view)Author: Stéphane Wirtel (matrixise)*(Python committer)Date: 2018-01-26 16:10
You are right, but...if there is an exception in the connect method before the init ofself.sock, the sock attribute will not exist and in this case, and onlyin this case, there will be an exception in the close method.your code will work fine if you use a try/finally but not in the casewhere we use the with statement, for example.with SMTP('myhost') as smtp:   smtp.do_something()If there is an exception in the __init__ of SMTP and self.sock is notinitialized -> traceback.
msg311553 -(view)Author: (amirjn)Date: 2018-02-03 13:55
same problem at apple.com
msg311554 -(view)Author: (amirjn)Date: 2018-02-03 13:57
<a href="apple.com">apple.com</a>
msg327409 -(view)Author: Giampaolo Rodola' (giampaolo.rodola)*(Python committer)Date: 2018-10-09 14:32
New changeset7b313971805ca9b53f181f7b97e5376d0b89dc06 by Giampaolo Rodola (Romuald Brunet) in branch 'master':bpo-32680 add default "sock" on SMTP objects (#5345)https://github.com/python/cpython/commit/7b313971805ca9b53f181f7b97e5376d0b89dc06
msg327410 -(view)Author: Giampaolo Rodola' (giampaolo.rodola)*(Python committer)Date: 2018-10-09 14:35
PR merged for 3.8 branch. I don't think such a simple change deserves a backport for previous Python versions. Closing this out as resolved.
History
DateUserActionArgs
2022-04-11 14:58:57adminsetgithub: 76861
2018-10-09 14:35:41giampaolo.rodolasetstatus: open -> closed
versions: + Python 3.8
messages: +msg327410

resolution: fixed
stage: patch review -> resolved
2018-10-09 14:32:01giampaolo.rodolasetnosy: +giampaolo.rodola
messages: +msg327409
2018-02-03 13:57:00amirjnsetmessages: +msg311554
2018-02-03 13:55:55amirjnsetnosy: +amirjn
messages: +msg311553
2018-01-26 16:10:58matrixisesetnosy: +matrixise
messages: +msg310774
2018-01-26 15:34:10Romualdsetmessages: +msg310766
2018-01-26 15:31:26Romualdsetkeywords: +patch
stage: patch review
pull_requests: +pull_request5192
2018-01-26 15:26:15Romualdcreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp