You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[sqlite3] the trace callback does not raise exceptions on error #89252
Note: 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:
assignee=Noneclosed_at=<Date2021-09-15.19:12:27.807>created_at=<Date2021-09-02.20:42:25.993>labels= ['extension-modules', '3.11', 'docs']
title='[sqlite3] the trace callback does not raise exceptions on error'updated_at=<Date2021-10-04.20:48:21.288>user='https://github.com/erlend-aasland'
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.
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.
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.
Activity
erlend-aasland commentedon Sep 2, 2021
Currently, two calls can raise exceptions in the _trace_callback() in Modules/_sqlite/connection.c:
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.
erlend-aasland commentedon Sep 7, 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.
encukou commentedon Sep 8, 2021
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.
erlend-aasland commentedon Sep 8, 2021
+1
ambv commentedon Sep 15, 2021
New changeset 51056b4 by Erlend Egeberg Aasland in branch 'main':
bpo-45089: Improve sqlite3 trace callback docs (GH-28238)
51056b4
ambv commentedon Sep 15, 2021
New changeset 87f0ac8 by Miss Islington (bot) in branch '3.10':
bpo-45089: Improve sqlite3 trace callback docs (GH-28238) (GH-28371)
87f0ac8
ambv commentedon Sep 15, 2021
New changeset 97802a8 by Miss Islington (bot) in branch '3.9':
bpo-45089: Improve sqlite3 trace callback docs (GH-28238) (GH-28372)
97802a8
ambv commentedon Sep 15, 2021
Thanks, Erlend! ✨ 🍰 ✨
pablogsal commentedon Oct 4, 2021
New changeset 6fc66d6 by Pablo Galindo (Miss Islington (bot)) in branch '3.10':
bpo-45089: Improve sqlite3 trace callback docs (GH-28238) (GH-28371)
6fc66d6