This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients kristjan.jonsson, ncoghlan, r.david.murray
Date 2013-08-07.23:36:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CADiSq7eBjrgUJPgvkp9NuuxW3oFdJxZKxDxZrMrZndy3437W6A@mail.gmail.com>
In-reply-to <1375892961.09.0.359583243118.issue18677@psf.upfronthosting.co.za>
Content
I pitched the idea of making it possible to skip the with statement body
quite some time ago, and Guido convinced me it was a bad idea for much the
same reason he chose PEP 343 over his original PEP 340 design: allowing
suppression of exceptions from __enter__ hides local control flow by
blurring the boundaries between with and if statements.

Regarding nested, we killed that because it was a bug magnet for context
managers that acquire the resource in __init__ (like file objects), not
because it didn't work.
It's trivial to recreate that API on top of ExitStack if you like it,
though. The only thing that doesn't work (relative to actual nested with
statements) is suppressing exceptions raised inside __enter__ methods.
History
Date User Action Args
2013-08-07 23:36:54ncoghlansetrecipients: + ncoghlan, kristjan.jonsson, r.david.murray
2013-08-07 23:36:54ncoghlanlinkissue18677 messages
2013-08-07 23:36:53ncoghlancreate