Skip to content

bpo-43269: Clean up sqlite3 file scope #24578

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 8 commits into from
Feb 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 10 additions & 5 deletions Modules/_sqlite/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
#include <limits.h>

/* only used internally */
pysqlite_Node* pysqlite_new_node(PyObject* key, PyObject* data)
static pysqlite_Node *
pysqlite_new_node(PyObject *key, PyObject *data)
{
pysqlite_Node* node;

Expand All @@ -43,7 +44,8 @@ pysqlite_Node* pysqlite_new_node(PyObject* key, PyObject* data)
return node;
}

void pysqlite_node_dealloc(pysqlite_Node* self)
static void
pysqlite_node_dealloc(pysqlite_Node *self)
{
PyTypeObject *tp = Py_TYPE(self);

Expand All @@ -54,7 +56,8 @@ void pysqlite_node_dealloc(pysqlite_Node* self)
Py_DECREF(tp);
}

int pysqlite_cache_init(pysqlite_Cache* self, PyObject* args, PyObject* kwargs)
static int
pysqlite_cache_init(pysqlite_Cache *self, PyObject *args, PyObject *kwargs)
{
PyObject* factory;
int size = 10;
Expand Down Expand Up @@ -85,7 +88,8 @@ int pysqlite_cache_init(pysqlite_Cache* self, PyObject* args, PyObject* kwargs)
return 0;
}

void pysqlite_cache_dealloc(pysqlite_Cache* self)
static void
pysqlite_cache_dealloc(pysqlite_Cache *self)
{
PyTypeObject *tp = Py_TYPE(self);
pysqlite_Node* node;
Expand Down Expand Up @@ -217,7 +221,8 @@ PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* key)
return Py_NewRef(node->data);
}

PyObject* pysqlite_cache_display(pysqlite_Cache* self, PyObject* args)
static PyObject *
pysqlite_cache_display(pysqlite_Cache *self, PyObject *args)
{
pysqlite_Node* ptr;
PyObject* prevkey;
Expand Down
20 changes: 14 additions & 6 deletions Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ static const char * const begin_statements[] = {
static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, PyObject* isolation_level, void *Py_UNUSED(ignored));
static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* self);


int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
static int
pysqlite_connection_init(pysqlite_Connection *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = {
"database", "timeout", "detect_types", "isolation_level",
Expand Down Expand Up @@ -193,7 +194,9 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
}

/* action in (ACTION_RESET, ACTION_FINALIZE) */
void pysqlite_do_all_statements(pysqlite_Connection* self, int action, int reset_cursors)
static void
pysqlite_do_all_statements(pysqlite_Connection *self, int action,
int reset_cursors)
{
int i;
PyObject* weakref;
Expand Down Expand Up @@ -225,7 +228,8 @@ void pysqlite_do_all_statements(pysqlite_Connection* self, int action, int reset
}
}

void pysqlite_connection_dealloc(pysqlite_Connection* self)
static void
pysqlite_connection_dealloc(pysqlite_Connection *self)
{
PyTypeObject *tp = Py_TYPE(self);

Expand Down Expand Up @@ -546,7 +550,9 @@ _pysqlite_set_result(sqlite3_context* context, PyObject* py_val)
return 0;
}

PyObject* _pysqlite_build_py_params(sqlite3_context *context, int argc, sqlite3_value** argv)
static PyObject *
_pysqlite_build_py_params(sqlite3_context *context, int argc,
sqlite3_value **argv)
{
PyObject* args;
int i;
Expand Down Expand Up @@ -1288,7 +1294,9 @@ pysqlite_connection_set_isolation_level(pysqlite_Connection* self, PyObject* iso
return 0;
}

PyObject* pysqlite_connection_call(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
static PyObject *
pysqlite_connection_call(pysqlite_Connection *self, PyObject *args,
PyObject *kwargs)
{
PyObject* sql;
pysqlite_Statement* statement;
Expand Down
5 changes: 2 additions & 3 deletions Modules/_sqlite/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class _sqlite3.Cursor "pysqlite_Cursor *" "pysqlite_CursorType"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b2072d8db95411d5]*/

PyObject* pysqlite_cursor_iternext(pysqlite_Cursor* self);

static const char errmsg_fetch_across_rollback[] = "Cursor needed to be reset because of commit/rollback and can no longer be fetched from.";

/*[clinic input]
Expand Down Expand Up @@ -746,7 +744,8 @@ pysqlite_cursor_executescript(pysqlite_Cursor *self, PyObject *script_obj)
}
}

PyObject* pysqlite_cursor_iternext(pysqlite_Cursor *self)
static PyObject *
pysqlite_cursor_iternext(pysqlite_Cursor *self)
{
PyObject* next_row_tuple;
PyObject* next_row;
Expand Down
7 changes: 5 additions & 2 deletions Modules/_sqlite/prepare_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@

#include "prepare_protocol.h"

int pysqlite_prepare_protocol_init(pysqlite_PrepareProtocol* self, PyObject* args, PyObject* kwargs)
static int
pysqlite_prepare_protocol_init(pysqlite_PrepareProtocol *self, PyObject *args,
PyObject *kwargs)
{
return 0;
}

void pysqlite_prepare_protocol_dealloc(pysqlite_PrepareProtocol* self)
static void
pysqlite_prepare_protocol_dealloc(pysqlite_PrepareProtocol *self)
{
PyTypeObject *tp = Py_TYPE(self);

Expand Down
6 changes: 4 additions & 2 deletions Modules/_sqlite/row.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class _sqlite3.Row "pysqlite_Row *" "pysqlite_RowType"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=384227da65f250fd]*/

void pysqlite_row_dealloc(pysqlite_Row* self)
static void
pysqlite_row_dealloc(pysqlite_Row *self)
{
PyTypeObject *tp = Py_TYPE(self);

Expand Down Expand Up @@ -105,7 +106,8 @@ equal_ignore_case(PyObject *left, PyObject *right)
return 1;
}

PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)
static PyObject *
pysqlite_row_subscript(pysqlite_Row *self, PyObject *idx)
{
Py_ssize_t _idx;
Py_ssize_t nitems, i;
Expand Down
3 changes: 2 additions & 1 deletion Modules/_sqlite/statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ void pysqlite_statement_mark_dirty(pysqlite_Statement* self)
self->in_use = 1;
}

void pysqlite_statement_dealloc(pysqlite_Statement* self)
static void
pysqlite_statement_dealloc(pysqlite_Statement *self)
{
PyTypeObject *tp = Py_TYPE(self);

Expand Down