rogerbinns / apsw

Another Python SQLite wrapper
https://rogerbinns.github.io/apsw/
Other
733 stars 97 forks source link

Investigate chaining exceptions #407

Closed rogerbinns closed 1 year ago

rogerbinns commented 1 year ago

There are many places in the code where exceptions can occur while already handling exceptions.

For example Connection.__exit__ may be called and then the execution tracer has an exception so rollback is attempted but sqlite3_mprintf then has an error etc.

It should be possible to chain the cascading exceptions using _PyErr_ChainExceptions - see PEP 490

rogerbinns commented 1 year ago

There is now a CHAIN_EXC macro in the code that does this. However in most places a secondary exception is not because of the developer's handling of the first exception, but rather SQLite deciding to do other things.