FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-44839: Raise more specific errors in sqlite3 by serhiy-storchaka · Pull Request #27613 · python/cpython · GitHub

Repository navigation

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension .c  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
Prev Previous commit
Next Next commit
Address review comments.
  • Loading branch information
serhiy-storchaka committed Aug 6, 2021
commit 1401a8413439bcc5e19c95b26417292cec026122
19 changes: 11 additions & 8 deletions Modules/_sqlite/connection.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,9 @@ _pysqlite_build_py_params(sqlite3_context *context, int argc,
return NULL;
}

// Checks the Python exception and sets the appropriate SQLite error code.
static void
_pysqlite_result_error(sqlite3_context *context, const char *msg)
set_sqlite_error(sqlite3_context *context, const char *msg)
{
assert(PyErr_Occurred());
if (PyErr_ExceptionMatches(PyExc_MemoryError)) {
Expand Down Expand Up @@ -667,7 +668,8 @@ _pysqlite_func_callback(sqlite3_context *context, int argc, sqlite3_value **argv
Py_DECREF(py_retval);
}
if (!ok) {
_pysqlite_result_error(context, "user-defined function raised exception");
set_sqlite_error(context,
"user-defined function raised exception");
Comment thread
serhiy-storchaka marked this conversation as resolved.
Resolved
}

PyGILState_Release(threadstate);
Expand All @@ -691,10 +693,9 @@ static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_

if (*aggregate_instance == NULL) {
*aggregate_instance = _PyObject_CallNoArg(aggregate_class);

if (PyErr_Occurred()) {
*aggregate_instance = 0;
_pysqlite_result_error(context, "user-defined aggregate's '__init__' method raised error");
if (!*aggregate_instance) {
set_sqlite_error(context,
"user-defined aggregate's '__init__' method raised error");
goto error;
}
}
Expand All @@ -713,7 +714,8 @@ static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_
Py_DECREF(args);

if (!function_result) {
_pysqlite_result_error(context, "user-defined aggregate's 'step' method raised error");
set_sqlite_error(context,
"user-defined aggregate's 'step' method raised error");
}

error:
Expand Down Expand Up @@ -761,7 +763,8 @@ _pysqlite_final_callback(sqlite3_context *context)
Py_DECREF(function_result);
}
if (!ok) {
_pysqlite_result_error(context, "user-defined aggregate's 'finalize' method raised error");
set_sqlite_error(context,
"user-defined aggregate's 'finalize' method raised error");
}

/* Restore the exception (if any) of the last call to step(),
Expand Down

Back | FazBrowse Home | New Git URL