[issue11767] Maildir iterator leaks file descriptors by default

R. David Murray report at bugs.python.org
Thu Apr 7 02:47:45 CEST 2011


R. David Murray <rdmurray at bitdance.com> added the comment:

get_file's promise is that what is returned is a file like object, so it not having a close() method would be an error.  So I don't think you need the try/except.  What I would suggest is to use the 'closing' context manager around the return statement.

As for tests, you could create a subclass with a custom get_file method that returns a mock object you can test to make sure the close method gets called, since Mailbox is the only place __getitem__ is defined.

Gah, I hit the wrong key an deleted your patch.  Reattaching.

----------
Added file: http://bugs.python.org/file21557/11767.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11767>
_______________________________________


More information about the Python-bugs-list mailing list