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

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to