8000 bpo-42064: Pass module state to trace, progress, and authorizer callbacks by erlend-aasland · Pull Request #27940 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-42064: Pass module state to trace, progress, and authorizer callbacks #27940

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

Merged
merged 17 commits into from
Sep 7, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix merge
  • Loading branch information
Erlend E. Aasland committed Sep 7, 2021
commit 32c2073e4da68086702ae15c6f794b2130a1b02d
10 changes: 5 additions & 5 deletions Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ progress_callback(void *ctx)

assert(ctx != NULL);
PyObject *callable = ((callback_context *)ctx)->callable;
ret = _PyObject_CallNoArg(ctx->callable);
ret = _PyObject_CallNoArg(callable);
if (!ret) {
/* abort query if error occurred */
rc = -1;
Expand Down Expand Up @@ -1042,7 +1042,6 @@ trace_callback(void *ctx, const char *statement_string)
PyObject *ret = NULL;
py_statement = PyUnicode_DecodeUTF8(statement_string,
strlen(statement_string), "replace");
callback_context *ctx = (callback_context *)user_arg;
assert(ctx != NULL);
if (py_statement) {
PyObject *callable = ((callback_context *)ctx)->callable;
Expand Down Expand Up @@ -1124,12 +1123,13 @@ pysqlite_connection_set_progress_handler_impl(pysqlite_Connection *self,
/* None clears the progress handler previously set */
sqlite3_progress_handler(self->db, 0, 0, (void*)0);
SET_CALLBACK_CONTEXT(self->progress_ctx, NULL);
} else {
}
else {
callback_context *ctx = create_callback_context(self->state, callable);
if (ctx == NULL) {
return NULL;
}
sqlite3_progress_handler(self->db, n, progress_handler, ctx);
sqlite3_progress_handler(self->db, n, progress_callback, ctx);
SET_CALLBACK_CONTEXT(self->progress_ctx, ctx);
}
Py_RETURN_NONE;
Expand Down Expand Up @@ -1179,7 +1179,7 @@ pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self,
#else
sqlite3_trace(self->db, trace_callback, ctx);
#endif
SET_CALLBACK_CONTEXT(self->trace_ctx, callable);
SET_CALLBACK_CONTEXT(self->trace_ctx, ctx);
}

Py_RETURN_NONE;
Expand Down
0