
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2018-01-26 15:26 byRomuald, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 5345 | merged | Romuald,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)*![]() | 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)*![]() | 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)*![]() | 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 | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:57 | admin | set | github: 76861 |
| 2018-10-09 14:35:41 | giampaolo.rodola | set | status: open -> closed versions: + Python 3.8 messages: +msg327410 resolution: fixed stage: patch review -> resolved |
| 2018-10-09 14:32:01 | giampaolo.rodola | set | nosy: +giampaolo.rodola messages: +msg327409 |
| 2018-02-03 13:57:00 | amirjn | set | messages: +msg311554 |
| 2018-02-03 13:55:55 | amirjn | set | nosy: +amirjn messages: +msg311553 |
| 2018-01-26 16:10:58 | matrixise | set | nosy: +matrixise messages: +msg310774 |
| 2018-01-26 15:34:10 | Romuald | set | messages: +msg310766 |
| 2018-01-26 15:31:26 | Romuald | set | keywords: +patch stage: patch review pull_requests: +pull_request5192 |
| 2018-01-26 15:26:15 | Romuald | create | |