Repository navigation
[sqlite3] the trace callback does not raise exceptions on error #89252
Description
Activity
Currently, two calls can raise exceptions in the _trace_callback() in Modules/_sqlite/connection.c:
- PyUnicode_DecodeUTF8() can raise an exception
- PyObject_CallOneArg() — calling the user callback — can raise an exception
Currently, we either PyErr_Print() the traceback, or we PyErr_Clear() it. In either case; we clear the current exception. The other SQLite callbacks pass some kind of return value back to SQLite to indicate failure (which is normally then passed to _pysqlite_seterror() via sqlite3_step() or sqlite3_finalize(), but the trace callback does not pass errors back to SQLite; we're unable to detect if the trace callback fails.
- added3.11only security fixesonly security fixesextension-modulesC modules in the Modules dirC modules in the Modules dir
on Sep 2, 2021 Quoting Petr from PR 28133:
Without the ability to tell SQLite to abort on trace failure, I doubt we can
do much better than the current behavior. Getting an exception and having
the data inserted seems quite irregular.Closing this issue as won't fix.
It *would* be possible to improve the documentation, though.
Say that it is only meant for debugging, document that exceptions are not propagated, and mention enable_callback_tracebacks.It *would* be possible to improve the documentation, though.
+1
Thanks, Erlend! ✨ 🍰 ✨
sqlite3trace callback #28133sqlite3trace callback docs #28238Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: