Nick Coghlan added the comment: I think you make a good case, but I already tried and failed to convince Guido of this in PEP 377 (see http://www.python.org/dev/peps/pep-0377/#rationale-for-change)
More importantly, see his quoted concerns in http://mail.python.org/pipermail/python-dev/2009-March/087263.html While you have come up with a much simpler *implementation* for PEP 377, which imposes no additional overhead in the typical case (unlike my implementation, which predated the SETUP_WITH opcode and avoided introducing one, which required wrapping every __enter__ call in a separate try/except block), it still adds a new builtin exception type, and I thing needs a new builtin constant as well. The latter comes in because I think the bound variable name still needs to be set to something, and rather than abusing any existing constant, I think a new SkipWith constant for both "don't call enter/exit" and "with statement body was skipped" would actually be clearer. I actually think explaining a custom exception and constant is less of a burden than explaining why factoring out certain constructs with @contextmanager and yield doesn't work properly (that's why I wrote PEP 377 in the first place), but Guido is the one that ultimately needs to be convinced of the gain. ---------- nosy: +gvanrossum _______________________________________ 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