Skip to content

bpo-44326: Remove unused members from pysqlite_Statement #26564

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 2 commits into from
Jun 6, 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
16 changes: 2 additions & 14 deletions Modules/_sqlite/statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ pysqlite_statement_create(pysqlite_Connection *connection, PyObject *sql)
return NULL;
}

self->db = connection->db;
self->st = NULL;
self->sql = Py_NewRef(sql);
self->in_use = 0;
self->is_dml = 0;
self->in_weakreflist = NULL;
Expand All @@ -110,7 +108,7 @@ pysqlite_statement_create(pysqlite_Connection *connection, PyObject *sql)
}

Py_BEGIN_ALLOW_THREADS
rc = sqlite3_prepare_v2(self->db,
rc = sqlite3_prepare_v2(connection->db,
sql_cstr,
(int)sql_cstr_len + 1,
&self->st,
Expand All @@ -120,7 +118,7 @@ pysqlite_statement_create(pysqlite_Connection *connection, PyObject *sql)
PyObject_GC_Track(self);

if (rc != SQLITE_OK) {
_pysqlite_seterror(self->db);
_pysqlite_seterror(connection->db);
goto error;
}

Expand Down Expand Up @@ -409,23 +407,14 @@ stmt_dealloc(pysqlite_Statement *self)
Py_END_ALLOW_THREADS
self->st = 0;
}
tp->tp_clear((PyObject *)self);
tp->tp_free(self);
Py_DECREF(tp);
}

static int
stmt_clear(pysqlite_Statement *self)
{
Py_CLEAR(self->sql);
return 0;
}

static int
stmt_traverse(pysqlite_Statement *self, visitproc visit, void *arg)
{
Py_VISIT(Py_TYPE(self));
Py_VISIT(self->sql);
return 0;
}

Expand Down Expand Up @@ -507,7 +496,6 @@ static PyType_Slot stmt_slots[] = {
{Py_tp_members, stmt_members},
{Py_tp_dealloc, stmt_dealloc},
{Py_tp_traverse, stmt_traverse},
{Py_tp_clear, stmt_clear},
{0, NULL},
};

Expand Down
2 changes: 0 additions & 2 deletions Modules/_sqlite/statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
typedef struct
{
PyObject_HEAD
sqlite3* db;
sqlite3_stmt* st;
PyObject* sql;
int in_use;
int is_dml;
PyObject* in_weakreflist; /* List of weak references */
Expand Down