Skip to content

[sqlite3] the trace callback does not raise exceptions on error #89252

Description

@erlend-aasland
BPO 45089
Nosy @encukou, @ambv, @pablogsal, @miss-islington, @erlend-aasland
PRs
  • bpo-45089: raise exceptions on error in sqlite3 trace callback #28133
  • bpo-45089: Improve sqlite3 trace callback docs #28238
  • [3.10] bpo-45089: Improve sqlite3 trace callback docs (GH-28238) #28371
  • [3.9] bpo-45089: Improve sqlite3 trace callback docs (GH-28238) #28372
  • Files
  • reproducer.py
  • 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 = None
    closed_at = <Date 2021-09-15.19:12:27.807>
    created_at = <Date 2021-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 = <Date 2021-10-04.20:48:21.288>
    user = 'https://github.com/erlend-aasland'

    bugs.python.org fields:

    activity = <Date 2021-10-04.20:48:21.288>
    actor = 'erlendaasland'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2021-09-15.19:12:27.807>
    closer = 'lukasz.langa'
    components = ['Documentation', 'Extension Modules']
    creation = <Date 2021-09-02.20:42:25.993>
    creator = 'erlendaasland'
    dependencies = []
    files = ['50259']
    hgrepos = []
    issue_num = 45089
    keywords = ['patch']
    message_count = 9.0
    messages = ['400955', '401283', '401353', '401354', '401880', '401885', '401887', '401888', '403179']
    nosy_count = 6.0
    nosy_names = ['petr.viktorin', 'docs@python', 'lukasz.langa', 'pablogsal', 'miss-islington', 'erlendaasland']
    pr_nums = ['28133', '28238', '28371', '28372']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue45089'
    versions = ['Python 3.11']

    Activity

    1. erlend-aasland commented on Sep 2, 2021

      @erlend-aasland
      ContributorAuthor

      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.

    2. erlend-aasland commented on Sep 7, 2021

      @erlend-aasland
      ContributorAuthor

      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.

    3. encukou commented on Sep 8, 2021

      @encukou
      Member

      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.

    4. reopened this on Sep 8, 2021
    5. reopened this on Sep 8, 2021
    6. erlend-aasland commented on Sep 8, 2021

      @erlend-aasland
      ContributorAuthor

      It *would* be possible to improve the documentation, though.

      +1

    7. ambv commented on Sep 15, 2021

      @ambv
      Contributor

      New changeset 51056b4 by Erlend Egeberg Aasland in branch 'main':
      bpo-45089: Improve sqlite3 trace callback docs (GH-28238)
      51056b4

    8. ambv commented on Sep 15, 2021

      @ambv
      Contributor

      New changeset 87f0ac8 by Miss Islington (bot) in branch '3.10':
      bpo-45089: Improve sqlite3 trace callback docs (GH-28238) (GH-28371)
      87f0ac8

    9. ambv commented on Sep 15, 2021

      @ambv
      Contributor

      New changeset 97802a8 by Miss Islington (bot) in branch '3.9':
      bpo-45089: Improve sqlite3 trace callback docs (GH-28238) (GH-28372)
      97802a8

    10. ambv commented on Sep 15, 2021

      @ambv
      Contributor

      Thanks, Erlend! ✨ 🍰 ✨

    11. pablogsal commented on Oct 4, 2021

      @pablogsal
      Member

      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

    12. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions