Skip to content

Commit bf838a6

Browse files
author
Erlend Egeberg Aasland
authored
bpo-43269: Clean up sqlite3 file scope (GH-24578)
1 parent d439fb3 commit bf838a6

File tree

6 files changed

+37
-19
lines changed

6 files changed

+37
-19
lines changed

Modules/_sqlite/cache.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
#include <limits.h>
2626

2727
/* only used internally */
28-
pysqlite_Node* pysqlite_new_node(PyObject* key, PyObject* data)
28+
static pysqlite_Node *
29+
pysqlite_new_node(PyObject *key, PyObject *data)
2930
{
3031
pysqlite_Node* node;
3132

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

46-
void pysqlite_node_dealloc(pysqlite_Node* self)
47+
static void
48+
pysqlite_node_dealloc(pysqlite_Node *self)
4749
{
4850
PyTypeObject *tp = Py_TYPE(self);
4951

@@ -54,7 +56,8 @@ void pysqlite_node_dealloc(pysqlite_Node* self)
5456
Py_DECREF(tp);
5557
}
5658

57-
int pysqlite_cache_init(pysqlite_Cache* self, PyObject* args, PyObject* kwargs)
59+
static int
60+
pysqlite_cache_init(pysqlite_Cache *self, PyObject *args, PyObject *kwargs)
5861
{
5962
PyObject* factory;
6063
int size = 10;
@@ -85,7 +88,8 @@ int pysqlite_cache_init(pysqlite_Cache* self, PyObject* args, PyObject* kwargs)
8588
return 0;
8689
}
8790

88-
void pysqlite_cache_dealloc(pysqlite_Cache* self)
91+
static void
92+
pysqlite_cache_dealloc(pysqlite_Cache *self)
8993
{
9094
PyTypeObject *tp = Py_TYPE(self);
9195
pysqlite_Node* node;
@@ -217,7 +221,8 @@ PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* key)
217221
return Py_NewRef(node->data);
218222
}
219223

220-
PyObject* pysqlite_cache_display(pysqlite_Cache* self, PyObject* args)
224+
static PyObject *
225+
pysqlite_cache_display(pysqlite_Cache *self, PyObject *args)
221226
{
222227
pysqlite_Node* ptr;
223228
PyObject* prevkey;

Modules/_sqlite/connection.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ static const char * const begin_statements[] = {
5757
static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, PyObject* isolation_level, void *Py_UNUSED(ignored));
5858
static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* self);
5959

60-
61-
int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
60+
static int
61+
pysqlite_connection_init(pysqlite_Connection *self, PyObject *args,
62+
PyObject *kwargs)
6263
{
6364
static char *kwlist[] = {
6465
"database", "timeout", "detect_types", "isolation_level",
@@ -193,7 +194,9 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
193194
}
194195

195196
/* action in (ACTION_RESET, ACTION_FINALIZE) */
196-
void pysqlite_do_all_statements(pysqlite_Connection* self, int action, int reset_cursors)
197+
static void
198+
pysqlite_do_all_statements(pysqlite_Connection *self, int action,
199+
int reset_cursors)
197200
{
198201
int i;
199202
PyObject* weakref;
@@ -225,7 +228,8 @@ void pysqlite_do_all_statements(pysqlite_Connection* self, int action, int reset
225228
}
226229
}
227230

228-
void pysqlite_connection_dealloc(pysqlite_Connection* self)
231+
static void
232+
pysqlite_connection_dealloc(pysqlite_Connection *self)
229233
{
230234
PyTypeObject *tp = Py_TYPE(self);
231235

@@ -546,7 +550,9 @@ _pysqlite_set_result(sqlite3_context* context, PyObject* py_val)
546550
return 0;
547551
}
548552

549-
PyObject* _pysqlite_build_py_params(sqlite3_context *context, int argc, sqlite3_value** argv)
553+
static PyObject *
554+
_pysqlite_build_py_params(sqlite3_context *context, int argc,
555+
sqlite3_value **argv)
550556
{
551557
PyObject* args;
552558
int i;
@@ -1288,7 +1294,9 @@ pysqlite_connection_set_isolation_level(pysqlite_Connection* self, PyObject* iso
12881294
return 0;
12891295
}
12901296

1291-
PyObject* pysqlite_connection_call(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
1297+
static PyObject *
1298+
pysqlite_connection_call(pysqlite_Connection *self, PyObject *args,
1299+
PyObject *kwargs)
12921300
{
12931301
PyObject* sql;
12941302
pysqlite_Statement* statement;

Modules/_sqlite/cursor.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ class _sqlite3.Cursor "pysqlite_Cursor *" "pysqlite_CursorType"
3232
[clinic start generated code]*/
3333
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b2072d8db95411d5]*/
3434

35-
PyObject* pysqlite_cursor_iternext(pysqlite_Cursor* self);
36-
3735
static const char errmsg_fetch_across_rollback[] = "Cursor needed to be reset because of commit/rollback and can no longer be fetched from.";
3836

3937
/*[clinic input]
@@ -746,7 +744,8 @@ pysqlite_cursor_executescript(pysqlite_Cursor *self, PyObject *script_obj)
746744
}
747745
}
748746

749-
PyObject* pysqlite_cursor_iternext(pysqlite_Cursor *self)
747+
static PyObject *
748+
pysqlite_cursor_iternext(pysqlite_Cursor *self)
750749
{
751750
PyObject* next_row_tuple;
752751
PyObject* next_row;

Modules/_sqlite/prepare_protocol.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@
2323

2424
#include "prepare_protocol.h"
2525

26-
int pysqlite_prepare_protocol_init(pysqlite_PrepareProtocol* self, PyObject* args, PyObject* kwargs)
26+
static int
27+
pysqlite_prepare_protocol_init(pysqlite_PrepareProtocol *self, PyObject *args,
28+
PyObject *kwargs)
2729
{
2830
return 0;
2931
}
3032

31-
void pysqlite_prepare_protocol_dealloc(pysqlite_PrepareProtocol* self)
33+
static void
34+
pysqlite_prepare_protocol_dealloc(pysqlite_PrepareProtocol *self)
3235
{
3336
PyTypeObject *tp = Py_TYPE(self);
3437

Modules/_sqlite/row.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class _sqlite3.Row "pysqlite_Row *" "pysqlite_RowType"
3131
[clinic start generated code]*/
3232
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=384227da65f250fd]*/
3333

34-
void pysqlite_row_dealloc(pysqlite_Row* self)
34+
static void
35+
pysqlite_row_dealloc(pysqlite_Row *self)
3536
{
3637
PyTypeObject *tp = Py_TYPE(self);
3738

@@ -105,7 +106,8 @@ equal_ignore_case(PyObject *left, PyObject *right)
105106
return 1;
106107
}
107108

108-
PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)
109+
static PyObject *
110+
pysqlite_row_subscript(pysqlite_Row *self, PyObject *idx)
109111
{
110112
Py_ssize_t _idx;
111113
Py_ssize_t nitems, i;

Modules/_sqlite/statement.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ void pysqlite_statement_mark_dirty(pysqlite_Statement* self)
368368
self->in_use = 1;
369369
}
370370

371-
void pysqlite_statement_dealloc(pysqlite_Statement* self)
371+
static void
372+
pysqlite_statement_dealloc(pysqlite_Statement *self)
372373
{
373374
PyTypeObject *tp = Py_TYPE(self);
374375

0 commit comments

Comments
 (0)