Issue 11289: smtplib context manager (original) (raw)

Created on 2011-02-22 17:05 by giampaolo.rodola, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
smtplib_context_manager.patch giampaolo.rodola,2011-02-22 17:18
Messages (11)
msg129096 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2011-02-22 17:05
Patch in attachment provides a context manager for SMTP class so that it can be used with the "with" statement.
msg129099 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2011-02-22 17:16
you didn't attach anything, Giampaolo.
msg129102 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2011-02-22 17:18
Ouch! Here. =)
msg129104 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2011-02-22 17:24
is print really necessary in the test? Also, I think it would be better to unpack the tuple in test, rather then index it.
msg129105 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2011-02-22 17:26
> is print really necessary in the test? no, my mistake
msg130971 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2011-03-15 13:32
A couple more minor issues: 1. Double space required at the beginning of the "Here is a ..." sentence in Doc/library/smtplib.rst 2. in __exit__ method: "msg" is the variable name assigned from docmd('QUIT') but "errmsg" is used when raising exception 3. in test I'd rather prefer seeing stmp.noop() unpacked: code, _ = smtp.noop() 4. extra line #118 in test_smtplib 5. is there any way to test SMTPResponseException?
msg131008 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2011-03-15 17:55
Thanks for the contribution! It seems like a reasonable new feature, so I'll get this landed in 3.3. Probably should use :versionadded: instead (thanks gps). I'll address SilentGhost's issues in the commit.
msg131017 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2011-03-15 18:40
@barry I have commit privileges, but no problem if you want to commit it.
msg131019 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2011-03-15 18:50
On Mar 15, 2011, at 06:40 PM, Giampaolo Rodola' wrote: > >Giampaolo Rodola' <g.rodola@gmail.com> added the comment: > >@barry I have commit privileges, but no problem if you want to commit it. @giampaolo: I'd like to do it (and am almost ready to), mostly to test out hg workflow, but also because I have some additions which address SilentGhost's comments. Thanks! (Don't worry, you'll get credit in NEWS :).
msg131020 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2011-03-15 18:51
Go on, no prob.
msg131025 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-03-15 19:24
New changeset a6a94cfb75e9 by Barry Warsaw in branch 'default': - Issue #11289: `smtp.SMTP` class becomes a context manager so it can be used http://hg.python.org/cpython/rev/a6a94cfb75e9
History
Date User Action Args
2022-04-11 14:57:13 admin set github: 55498
2011-03-15 19:28:10 giampaolo.rodola set nosy:barry, pitrou, giampaolo.rodola, SilentGhost, python-devtype: enhancementstage: resolved
2011-03-15 19:27:38 barry set nosy:barry, pitrou, giampaolo.rodola, SilentGhost, python-devresolution: accepted
2011-03-15 19:27:25 barry set status: open -> closednosy:barry, pitrou, giampaolo.rodola, SilentGhost, python-dev
2011-03-15 19:24:06 python-dev set nosy: + python-devmessages: +
2011-03-15 18:51:51 giampaolo.rodola set nosy:barry, pitrou, giampaolo.rodola, SilentGhostmessages: +
2011-03-15 18:50:28 barry set nosy:barry, pitrou, giampaolo.rodola, SilentGhostmessages: +
2011-03-15 18:40:27 giampaolo.rodola set nosy:barry, pitrou, giampaolo.rodola, SilentGhostmessages: +
2011-03-15 18:33:13 SilentGhost link issue4972 dependencies
2011-03-15 17:55:35 barry set assignee: barrymessages: + nosy: + barry
2011-03-15 13:32:31 SilentGhost set nosy:pitrou, giampaolo.rodola, SilentGhostmessages: +
2011-02-22 17:26:00 giampaolo.rodola set nosy:pitrou, giampaolo.rodola, SilentGhostmessages: +
2011-02-22 17:24:26 SilentGhost set nosy:pitrou, giampaolo.rodola, SilentGhostmessages: +
2011-02-22 17🔞35 giampaolo.rodola set files: + smtplib_context_manager.patchmessages: + keywords: + patchnosy:pitrou, giampaolo.rodola, SilentGhost
2011-02-22 17:16:17 SilentGhost set nosy: + SilentGhostmessages: + components: + Library (Lib)
2011-02-22 17:05:04 giampaolo.rodola create