[issue19282] dbm.open should be a context manager

Terry J. Reedy report at bugs.python.org
Sat Oct 19 02:16:08 CEST 2013


Terry J. Reedy added the comment:

I agree with the revised title. Test_context_manager() should also test that db is actually closed after the with statement. I presume you can use self.assertRaises and try to do something with db that will fail if it is properly closed.

        with self.assertRaises(<NotOpenError>):
            db['a'] = 'a'  # or whatever

I haven't looked at the C code.

----------
nosy: +terry.reedy
stage: needs patch -> patch review
title: dbm is not a context manager -> dbm.open should be a context manager

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


More information about the Python-bugs-list mailing list