Kristján Valur Jónsson added the comment: I've modified the patch. The problem that nested_delayed was trying to solve are "hybrid" context managers, ones that allocate resources during __init__ and release them at exit. A proper context manager should allocate resources during __enter__, and thus a number of them can be created upfront with impunity.
Added contextlib.proper to turn a hybrid context manager into a proper one by instantiating the hybrid in a delayed fashion. added contextlib.opened() as a special case that does open() properly. With this change, and the ability to nest error handling of exceptions stemming from __enter__(), nested now works as intended. ---------- Added file: http://bugs.python.org/file31195/contextmanagerexit.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18677> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com