gh-129354: Use PyErr_FormatUnraisable() function (#129524)

Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().

Update test_sqlite3 tests.

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
Victor Stinner 2025-02-03 13:10:18 +01:00 committed by GitHub
parent 04264a286e
commit 218f205f20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 21 deletions

View file

@ -497,7 +497,8 @@ connection_finalize(PyObject *self)
if (PyErr_ResourceWarning(self, 1, "unclosed database in %R", self)) {
/* Spurious errors can appear at shutdown */
if (PyErr_ExceptionMatches(PyExc_Warning)) {
PyErr_WriteUnraisable(self);
PyErr_FormatUnraisable("Exception ignored while finalizing "
"database connection %R", self);
}
}
}
@ -506,7 +507,8 @@ connection_finalize(PyObject *self)
PyErr_Clear();
}
else {
PyErr_WriteUnraisable((PyObject *)self);
PyErr_FormatUnraisable("Exception ignored while closing database %R",
self);
}
}
@ -893,7 +895,8 @@ print_or_clear_traceback(callback_context *ctx)
assert(ctx != NULL);
assert(ctx->state != NULL);
if (ctx->state->enable_callback_tracebacks) {
PyErr_WriteUnraisable(ctx->callable);
PyErr_FormatUnraisable("Exception ignored on sqlite3 callback %R",
ctx->callable);
}
else {
PyErr_Clear();