Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
erlend-aasland opened this issue Sep 2, 2021 · 9 comments
Closed
Labels
3.11 only security fixes docs Documentation in the Doc dir extension-modules C modules in the Modules dir topic-sqlite3

Comments

@erlend-aasland
Copy link
Contributor

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']

    @erlend-aasland
    Copy link
    Contributor Author

    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.

    @erlend-aasland erlend-aasland added 3.11 only security fixes extension-modules C modules in the Modules dir labels Sep 2, 2021
    @erlend-aasland
    Copy link
    Contributor Author

    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
    Copy link
    Member

    encukou commented 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.

    @encukou encukou added the docs Documentation in the Doc dir label Sep 8, 2021
    @encukou encukou reopened this Sep 8, 2021
    @encukou encukou added the docs Documentation in the Doc dir label Sep 8, 2021
    @encukou encukou reopened this Sep 8, 2021
    @erlend-aasland
    Copy link
    Contributor Author

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

    +1

    @ambv
    Copy link
    Contributor

    ambv commented Sep 15, 2021

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

    @ambv
    Copy link
    Contributor

    ambv commented 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
    Copy link
    Contributor

    ambv commented 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
    Copy link
    Contributor

    ambv commented Sep 15, 2021

    Thanks, Erlend! ✨ 🍰 ✨

    @ambv ambv closed this as completed Sep 15, 2021
    @ambv ambv closed this as completed Sep 15, 2021
    @pablogsal
    Copy link
    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

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes docs Documentation in the Doc dir extension-modules C modules in the Modules dir topic-sqlite3
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants