This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [sqlite3] the trace callback does not raise exceptions on error
Type: Stage: resolved
Components: Documentation, Extension Modules Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, erlendaasland, lukasz.langa, miss-islington, pablogsal, petr.viktorin
Priority: normal Keywords: patch

Created on 2021-09-02 20:42 by erlendaasland, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
reproducer.py erlendaasland, 2021-09-02 20:42
Pull Requests
URL Status Linked Edit
PR 28133 closed erlendaasland, 2021-09-02 21:10
PR 28238 merged erlendaasland, 2021-09-08 12:01
PR 28371 merged miss-islington, 2021-09-15 18:39
PR 28372 merged miss-islington, 2021-09-15 18:39
Messages (9)
msg400955 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-09-02 20:42
Currently, two calls can raise exceptions in the _trace_callback() in Modules/_sqlite/connection.c:

  1. PyUnicode_DecodeUTF8() can raise an exception
  2. 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.
msg401283 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-09-07 14:15
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.
msg401353 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2021-09-08 07:56
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.
msg401354 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-09-08 08:16
> It *would* be possible to improve the documentation, though.

+1
msg401880 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-15 18:39
New changeset 51056b40e711d84692d099ac8970077b33c7fafd by Erlend Egeberg Aasland in branch 'main':
bpo-45089: Improve sqlite3 trace callback docs (GH-28238)
https://github.com/python/cpython/commit/51056b40e711d84692d099ac8970077b33c7fafd
msg401885 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-15 19:00
New changeset 87f0ac8c1de83ac63447b9fe799dfb1657a5a9db by Miss Islington (bot) in branch '3.10':
bpo-45089: Improve sqlite3 trace callback docs (GH-28238) (GH-28371)
https://github.com/python/cpython/commit/87f0ac8c1de83ac63447b9fe799dfb1657a5a9db
msg401887 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-15 19:09
New changeset 97802a8edb3f15aef9ecc1cac97c4c1b4ed3fdfc by Miss Islington (bot) in branch '3.9':
bpo-45089: Improve sqlite3 trace callback docs (GH-28238) (GH-28372)
https://github.com/python/cpython/commit/97802a8edb3f15aef9ecc1cac97c4c1b4ed3fdfc
msg401888 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-15 19:10
Thanks, Erlend! ✨ 🍰 ✨
msg403179 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-10-04 19:18
New changeset 6fc66d6b9d39fa7a5a8692062d54b5a6a1aa0283 by Pablo Galindo (Miss Islington (bot)) in branch '3.10':
bpo-45089: Improve sqlite3 trace callback docs (GH-28238) (GH-28371)
https://github.com/python/cpython/commit/6fc66d6b9d39fa7a5a8692062d54b5a6a1aa0283
History
Date User Action Args
2022-04-11 14:59:49adminsetgithub: 89252
2021-10-04 20:48:21erlendaaslandsetresolution: wont fix -> fixed
2021-10-04 19:18:44pablogsalsetnosy: + pablogsal
messages: + msg403179
2021-09-15 19:12:27lukasz.langasetstatus: open -> closed
stage: patch review -> resolved
2021-09-15 19:10:10lukasz.langasetmessages: + msg401888
2021-09-15 19:09:35lukasz.langasetmessages: + msg401887
2021-09-15 19:00:10lukasz.langasetmessages: + msg401885
2021-09-15 18:39:19miss-islingtonsetpull_requests: + pull_request26786
2021-09-15 18:39:13miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request26785
2021-09-15 18:39:10lukasz.langasetnosy: + lukasz.langa
messages: + msg401880
2021-09-08 12:01:09erlendaaslandsetstage: resolved -> patch review
pull_requests: + pull_request26658
2021-09-08 08:16:50erlendaaslandsetmessages: + msg401354
2021-09-08 07:56:00petr.viktorinsetstatus: closed -> open

nosy: + petr.viktorin, docs@python
messages: + msg401353

assignee: docs@python
components: + Documentation
2021-09-07 14:15:09erlendaaslandsetstatus: open -> closed
resolution: wont fix
messages: + msg401283

stage: patch review -> resolved
2021-09-02 21:10:57erlendaaslandsetkeywords: + patch
stage: patch review
pull_requests: + pull_request26571
2021-09-02 20:42:25erlendaaslandcreate