Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smtplib context manager #55498

Closed
giampaolo opened this issue Feb 22, 2011 · 11 comments
Closed

smtplib context manager #55498

giampaolo opened this issue Feb 22, 2011 · 11 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@giampaolo
Copy link
Contributor

BPO 11289
Nosy @warsaw, @pitrou, @giampaolo
Files
  • smtplib_context_manager.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/warsaw'
    closed_at = <Date 2011-03-15.19:27:25.009>
    created_at = <Date 2011-02-22.17:05:04.471>
    labels = ['type-feature', 'library']
    title = 'smtplib context manager'
    updated_at = <Date 2011-03-15.19:28:10.829>
    user = 'https://github.com/giampaolo'

    bugs.python.org fields:

    activity = <Date 2011-03-15.19:28:10.829>
    actor = 'giampaolo.rodola'
    assignee = 'barry'
    closed = True
    closed_date = <Date 2011-03-15.19:27:25.009>
    closer = 'barry'
    components = ['Library (Lib)']
    creation = <Date 2011-02-22.17:05:04.471>
    creator = 'giampaolo.rodola'
    dependencies = []
    files = ['20845']
    hgrepos = []
    issue_num = 11289
    keywords = ['patch']
    message_count = 11.0
    messages = ['129096', '129099', '129102', '129104', '129105', '130971', '131008', '131017', '131019', '131020', '131025']
    nosy_count = 5.0
    nosy_names = ['barry', 'pitrou', 'giampaolo.rodola', 'SilentGhost', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue11289'
    versions = ['Python 3.3']

    @giampaolo
    Copy link
    Contributor Author

    Patch in attachment provides a context manager for SMTP class so that it can be used with the "with" statement.

    @SilentGhost
    Copy link
    Mannequin

    SilentGhost mannequin commented Feb 22, 2011

    you didn't attach anything, Giampaolo.

    @SilentGhost SilentGhost mannequin added the stdlib Python modules in the Lib dir label Feb 22, 2011
    @giampaolo
    Copy link
    Contributor Author

    Ouch! Here. =)

    @SilentGhost
    Copy link
    Mannequin

    SilentGhost mannequin commented Feb 22, 2011

    is print really necessary in the test?

    Also, I think it would be better to unpack the tuple in test, rather then index it.

    @giampaolo
    Copy link
    Contributor Author

    is print really necessary in the test?

    no, my mistake

    @SilentGhost
    Copy link
    Mannequin

    SilentGhost mannequin commented Mar 15, 2011

    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 Add developer guide link to README.rst #118 in test_smtplib
    5. is there any way to test SMTPResponseException?

    @warsaw
    Copy link
    Member

    warsaw commented Mar 15, 2011

    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.

    @warsaw warsaw self-assigned this Mar 15, 2011
    @giampaolo
    Copy link
    Contributor Author

    @barry I have commit privileges, but no problem if you want to commit it.

    @warsaw
    Copy link
    Member

    warsaw commented Mar 15, 2011

    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 :).

    @giampaolo
    Copy link
    Contributor Author

    Go on, no prob.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 15, 2011

    New changeset a6a94cfb75e9 by Barry Warsaw in branch 'default':

    @warsaw warsaw closed this as completed Mar 15, 2011
    @giampaolo giampaolo added the type-feature A feature request or enhancement label Mar 15, 2011
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants