[issue18677] Enhanced context managers with ContextManagerExit and None

Kristján Valur Jónsson report at bugs.python.org
Thu Aug 8 02:09:59 CEST 2013


Kristján Valur Jónsson added the comment:

Hi there.
"allowing
suppression of exceptions from __enter__ hides local control flow by
blurring the boundaries between with and if statements.
"
I'm not sure what this means.  To me, it is a serious language design flaw that you can write a context manager, and it has a well known interface that you can invoke manually, but that you cannot take two existing context managers and assemble them into a nested one, correctly, however much you wiggle.
In my mind, allowing context managers to skip the managed body breaks new ground.  Both, by allowing this "combination" to be possible.  And also by opening up new and exciting applications for context managers.  If you saw Raymond's talk last Pycon, you should feel inspired to do new and exciting things with them.

the bug-magnet you speak of I already addressed in my patch with nested-delayed, more as a measure of completeness (address both the problems that old "nested" had.  The more serious bug (IMHO) is the suppression of __enter__ exceptions.

----------

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


More information about the Python-bugs-list mailing list