8000 bpo-40956: Convert _sqlite3.Cursor to Argument Clinic by erlend-aasland · Pull Request #24007 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
8000

bpo-40956: Convert _sqlite3.Cursor to Argument Clinic #24007

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 6 commits into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
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 Prev 8000 ious commit
Next Next commit
Address review: fix execute() and executemany() specs
  • Loading branch information
Erlend E. Aasland committed Dec 30, 2020
commit e9535b83a13acb1b7b9b63ba43cbb57834d2e9cb
20 changes: 8 additions & 12 deletions Modules/_sqlite/clinic/cursor.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pysqlite_cursor_init(PyObject *self, PyObject *args, PyObject *kwargs)
}

PyDoc_STRVAR(pysqlite_cursor_execute__doc__,
"execute($self, sql, parameters=<unrepresentable>, /)\n"
"execute($self, sql, parameters=(), /)\n"
"--\n"
"\n"
"Executes a SQL statement.");
Expand Down Expand Up @@ -73,7 +73,7 @@ pysqlite_cursor_execute(pysqlite_Cursor *self, PyObject *const *args, Py_ssize_t
}

PyDoc_STRVAR(pysqlite_cursor_executemany__doc__,
"executemany($self, sql, parameters=<unrepresentable>, /)\n"
"executemany($self, sql, seq_of_parameters, /)\n"
"--\n"
"\n"
"Repeatedly executes a SQL statement.");
Expand All @@ -83,16 +83,16 @@ PyDoc_STRVAR(pysqlite_cursor_executemany__doc__,

static PyObject *
pysqlite_cursor_executemany_impl(pysqlite_Cursor *self, PyObject *sql,
PyObject *parameters);
PyObject *seq_of_parameters);

static PyObject *
pysqlite_cursor_executemany(pysqlite_Cursor *self, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *sql;
PyObject *parameters = NULL;
PyObject *seq_of_parameters;

if (!_PyArg_CheckPositional("executemany", nargs, 1, 2)) {
if (!_PyArg_CheckPositional("executemany", nargs, 2, 2)) {
goto exit;
}
if (!PyUnicode_Check(args[0])) {
Expand All @@ -103,12 +103,8 @@ pysqlite_cursor_executemany(pysqlite_Cursor *self, PyObject *const *args, Py_ssi
goto exit;
}
sql = args[0];
if (nargs < 2) {
goto skip_optional;
}
parameters = args[1];
skip_optional:
return_value = pysqlite_cursor_executemany_impl(self, sql, parameters);
seq_of_parameters = args[1];
return_value = pysqlite_cursor_executemany_impl(self, sql, seq_of_parameters);

exit:
return return_value;
Expand Down Expand Up @@ -283,4 +279,4 @@ pysqlite_cursor_close(pysqlite_Cursor *self, PyObject *Py_UNUSED(ignored))
{
return pysqlite_cursor_close_impl(self);
}
/*[clinic end generated code: output=29b5b24ed34ba996 input=a9049054013a1b77]*/
/*[clinic end generated code: output=84d4ba48a211657b input=a9049054013a1b77]*/
10 changes: 5 additions & 5 deletions Modules/_sqlite/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
_sqlite3.Cursor.execute as pysqlite_cursor_execute

sql: unicode
parameters: object = NULL
parameters: object(c_default = 'NULL') = ()
/

Executes a SQL statement.
Expand All @@ -622,7 +622,7 @@ Executes a SQL statement.
static PyObject *
pysqlite_cursor_execute_impl(pysqlite_Cursor *self, PyObject *sql,
PyObject *parameters)
/*[clinic end generated code: output=d81b4655c7c0bbad input=f146ded55ff8c7d4]*/
/*[clinic end generated code: output=d81b4655c7c0bbad input=91d7bb36f127f597]*/
{
return _pysqlite_query_execute(self, 0, sql, parameters);
}
Expand All @@ -631,16 +631,16 @@ pysqlite_cursor_execute_impl(pysqlite_Cursor *self, PyObject *sql,
_sqlite3.Cursor.executemany as pysqlite_cursor_executemany

sql: unicode
parameters: object = NULL
seq_of_parameters: object
/

Repeatedly executes a SQL statement.
[clinic start generated code]*/

static PyObject *
pysqlite_cursor_executemany_impl(pysqlite_Cursor *self, PyObject *sql,
PyObject *parameters)
/*[clinic end generated code: output=df8e2d0b7300aab6 input=fa99d0eb3dd5971e]*/
PyObject *seq_of_parameters)
/*[clinic end generated code: output=2c65a3c4733fb5d8 input=440707b7af87fba8]*/
{
return _pysqlite_query_execute(self, 1, sql, parameters);
}
Expand Down
0