[RFC] Add run_cleanup, do_with_cleanup
Andrew Bennetts
andrew.bennetts at canonical.com
Thu Sep 24 08:22:28 BST 2009
Martin Pool wrote:
> 2009/9/24 Stephen J. Turnbull <stephen at xemacs.org>:
>
> > I believe Guido acknowledged not allowing the more compact notation in
> > the first place to be excessive caution, but it's not impossible to
> > distinguish exceptions raised by try_func from those raised by
> > final_func.
> >
> > So what's the problem? You want to do this without fixing all the
> > broken try ... finally blocks?
>
> It's not _impossible_, we just don't want to add boilerplate to
> everything that uses a try/finally block. There are many more of them
> than there are distinct types of cleanup to run.
Especially when the boilerplate involved is just complex enough that it
would be error-prone.
e.g. your proposed boilerplate appears to be missing a raise in the except
block... (unless you also suggest boilerplate in every final_func to start with
saving sys.exc_info() and then finally reraise it!)
-Andrew.
More information about the bazaar
mailing list