[Python-Dev] PEP 343 rewrite complete
Arnold deVos
adv at langdale.com.au
Thu Jun 2 16:14:49 CEST 2005
Arnold deVos wrote:
>
> This template eats eats the exception, which will cause a RuntimeError
> in the proposed Wrapper, I think. A raise after rollback is needed.
Actually, the Wrapper as written in the PEP does not raise RuntimeError
if the generator catches a block's exception.
Shouldn't the relevant clause in the Wrapper go like this:
try:
self.gen.throw(type, value, traceback)
except type:
return
except StopIteration:
raise RuntimeError("generator caught exception")
else:
raise RuntimeError("generator didn't stop")
And the transaction template would go like this (re-raising the exception):
@with_template
def transactional(db):
db.begin()
try:
yield None
except:
db.rollback()
raise
else:
db.commit()
At least this is what I gleaned from the earlier threads. It means that
the template does not appear to supress an exception that it cannot
actually supress.
- Arnold
More information about the Python-Dev
mailing list