R. David Murray <rdmur...@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 <rep...@bugs.python.org> <http://bugs.python.org/issue11767> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com