Skip to content

Commit 0d12f24

Browse files
author
Erlend Egeberg Aasland
authored
bpo-44326: Remove unused members from pysqlite_Statement (GH-26564)
* Remove unused db member of pysqlite_Statement * Remove unused sql method from statement object
1 parent 505624e commit 0d12f24

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

Modules/_sqlite/statement.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ pysqlite_statement_create(pysqlite_Connection *connection, PyObject *sql)
8484
return NULL;
8585
}
8686

87-
self->db = connection->db;
8887
self->st = NULL;
89-
self->sql = Py_NewRef(sql);
9088
self->in_use = 0;
9189
self->is_dml = 0;
9290
self->in_weakreflist = NULL;
@@ -110,7 +108,7 @@ pysqlite_statement_create(pysqlite_Connection *connection, PyObject *sql)
110108
}
111109

112110
Py_BEGIN_ALLOW_THREADS
113-
rc = sqlite3_prepare_v2(self->db,
111+
rc = sqlite3_prepare_v2(connection->db,
114112
sql_cstr,
115113
(int)sql_cstr_len + 1,
116114
&self->st,
@@ -120,7 +118,7 @@ pysqlite_statement_create(pysqlite_Connection *connection, PyObject *sql)
120118
PyObject_GC_Track(self);
121119

122120
if (rc != SQLITE_OK) {
123-
_pysqlite_seterror(self->db);
121+
_pysqlite_seterror(connection->db);
124122
goto error;
125123
}
126124

@@ -409,23 +407,14 @@ stmt_dealloc(pysqlite_Statement *self)
409407
Py_END_ALLOW_THREADS
410408
self->st = 0;
411409
}
412-
tp->tp_clear((PyObject *)self);
413410
tp->tp_free(self);
414411
Py_DECREF(tp);
415412
}
416413

417-
static int
418-
stmt_clear(pysqlite_Statement *self)
419-
{
420-
Py_CLEAR(self->sql);
421-
return 0;
422-
}
423-
424414
static int
425415
stmt_traverse(pysqlite_Statement *self, visitproc visit, void *arg)
426416
{
427417
Py_VISIT(Py_TYPE(self));
428-
Py_VISIT(self->sql);
429418
return 0;
430419
}
431420

@@ -507,7 +496,6 @@ static PyType_Slot stmt_slots[] = {
507496
{Py_tp_members, stmt_members},
508497
{Py_tp_dealloc, stmt_dealloc},
509498
{Py_tp_traverse, stmt_traverse},
510-
{Py_tp_clear, stmt_clear},
511499
{0, NULL},
512500
};
513501

Modules/_sqlite/statement.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
typedef struct
3333
{
3434
PyObject_HEAD
35-
sqlite3* db;
3635
sqlite3_stmt* st;
37-
PyObject* sql;
3836
int in_use;
3937
int is_dml;
4038
PyObject* in_weakreflist; /* List of weak references */

0 commit comments

Comments
 (0)