[New-bugs-announce] [issue32234] Add context management to mailbox.Mailbox

sblondon report at bugs.python.org
Wed Dec 6 10:28:26 EST 2017


New submission from sblondon <stephane.blondon at gmail.com>:

mailbox.Mailbox has a .close() method that should be called at the end of Mailbox use.
I think it would be nice to use Mailbox instances with a 'with' statement so .close() will be called it automatically. So there is no need to check for which format it's required (yes for mbox, no for Maildir, etc.)

So the source code:
mbox = mailbox.mbox("/path/to/mbox")
...
mbox.close()

could become:
with mailbox.mbox("/path/to/mbox") as mbox:
    ...

----------
components: Library (Lib)
messages: 307744
nosy: sblondon
priority: normal
severity: normal
status: open
title: Add context management to mailbox.Mailbox
type: enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32234>
_______________________________________


More information about the New-bugs-announce mailing list