bpo-43269: Clean up sqlite3 file scope (GH-24578)

This commit is contained in:
Erlend Egeberg Aasland 2021-02-21 01:29:19 +01:00 committed by GitHub
parent d439fb304c
commit bf838a6e7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 19 deletions

View File

@ -25,7 +25,8 @@
#include <limits.h> #include <limits.h>
/* only used internally */ /* 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; pysqlite_Node* node;
@ -43,7 +44,8 @@ pysqlite_Node* pysqlite_new_node(PyObject* key, PyObject* data)
return node; return node;
} }
void pysqlite_node_dealloc(pysqlite_Node* self) static void
pysqlite_node_dealloc(pysqlite_Node *self)
{ {
PyTypeObject *tp = Py_TYPE(self); PyTypeObject *tp = Py_TYPE(self);
@ -54,7 +56,8 @@ void pysqlite_node_dealloc(pysqlite_Node* self)
Py_DECREF(tp); 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; PyObject* factory;
int size = 10; int size = 10;
@ -85,7 +88,8 @@ int pysqlite_cache_init(pysqlite_Cache* self, PyObject* args, PyObject* kwargs)
return 0; return 0;
} }
void pysqlite_cache_dealloc(pysqlite_Cache* self) static void
pysqlite_cache_dealloc(pysqlite_Cache *self)
{ {
PyTypeObject *tp = Py_TYPE(self); PyTypeObject *tp = Py_TYPE(self);
pysqlite_Node* node; pysqlite_Node* node;
@ -217,7 +221,8 @@ PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* key)
return Py_NewRef(node->data); 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; pysqlite_Node* ptr;
PyObject* prevkey; PyObject* prevkey;

View File

@ -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 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); static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* self);
static int
int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) pysqlite_connection_init(pysqlite_Connection *self, PyObject *args,
PyObject *kwargs)
{ {
static char *kwlist[] = { static char *kwlist[] = {
"database", "timeout", "detect_types", "isolation_level", "database", "timeout", "detect_types", "isolation_level",
@ -193,7 +194,9 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
} }
/* action in (ACTION_RESET, ACTION_FINALIZE) */ /* 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; int i;
PyObject* weakref; PyObject* weakref;
@ -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); PyTypeObject *tp = Py_TYPE(self);
@ -546,7 +550,9 @@ _pysqlite_set_result(sqlite3_context* context, PyObject* py_val)
return 0; 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; PyObject* args;
int i; int i;
@ -1288,7 +1294,9 @@ pysqlite_connection_set_isolation_level(pysqlite_Connection* self, PyObject* iso
return 0; 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; PyObject* sql;
pysqlite_Statement* statement; pysqlite_Statement* statement;

View File

@ -32,8 +32,6 @@ class _sqlite3.Cursor "pysqlite_Cursor *" "pysqlite_CursorType"
[clinic start generated code]*/ [clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b2072d8db95411d5]*/ /*[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."; 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] /*[clinic input]
@ -746,7 +744,8 @@ error:
} }
} }
PyObject* pysqlite_cursor_iternext(pysqlite_Cursor *self) static PyObject *
pysqlite_cursor_iternext(pysqlite_Cursor *self)
{ {
PyObject* next_row_tuple; PyObject* next_row_tuple;
PyObject* next_row; PyObject* next_row;

View File

@ -23,12 +23,15 @@
#include "prepare_protocol.h" #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; return 0;
} }
void pysqlite_prepare_protocol_dealloc(pysqlite_PrepareProtocol* self) static void
pysqlite_prepare_protocol_dealloc(pysqlite_PrepareProtocol *self)
{ {
PyTypeObject *tp = Py_TYPE(self); PyTypeObject *tp = Py_TYPE(self);

View File

@ -31,7 +31,8 @@ class _sqlite3.Row "pysqlite_Row *" "pysqlite_RowType"
[clinic start generated code]*/ [clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=384227da65f250fd]*/ /*[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); PyTypeObject *tp = Py_TYPE(self);
@ -105,7 +106,8 @@ equal_ignore_case(PyObject *left, PyObject *right)
return 1; 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 _idx;
Py_ssize_t nitems, i; Py_ssize_t nitems, i;

View File

@ -368,7 +368,8 @@ void pysqlite_statement_mark_dirty(pysqlite_Statement* self)
self->in_use = 1; self->in_use = 1;
} }
void pysqlite_statement_dealloc(pysqlite_Statement* self) static void
pysqlite_statement_dealloc(pysqlite_Statement *self)
{ {
PyTypeObject *tp = Py_TYPE(self); PyTypeObject *tp = Py_TYPE(self);