[Python-Dev] PEP 343 rewrite complete
Arnold deVos
adv at langdale.com.au
Fri Jun 3 02:49:49 CEST 2005
Guido van Rossum wrote:
>
> [...] a generator doing cleanup depending on the
> exception thrown (like the transactional() example below) can
> *catch* the exception thrown if it wants to and doesn't have to
> worry about re-raising it. I find this more convenient for the
> generator writer. Against this was brought in that the
> generator *appears* to suppress an exception that it cannot
> suppress: the transactional() example would be more clear
> according to this view if it re-raised the original exception
> after the call to db.rollback(). [...]
Of course, the explicit re-raise is only needed in a minority of use
cases where the exception is caught. Two additional points in favour of
this:
- refactoring a naked try as a with + template is more direct and
uniform across all use cases.
- it is upwards compatible if the prohibition on templates suppressing
exceptions is ever reconsidered. (Flow control macro discussion not
withstanding.)
- Arnold
More information about the Python-Dev
mailing list