summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/module.c
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2021-10-27 11:12:21 (GMT)
committerGitHub <noreply@github.com>2021-10-27 11:12:21 (GMT)
commit8f24b7dbcbd83311dad510863d8cb41f0e91b464 (patch)
tree036b2a0f04c7c1b9009ea4bb0d904cde920bd84c /Modules/_sqlite/module.c
parent82a662e5216a9b3969054c540a759a9493468510 (diff)
downloadcpython-8f24b7dbcbd83311dad510863d8cb41f0e91b464.zip
cpython-8f24b7dbcbd83311dad510863d8cb41f0e91b464.tar.gz
cpython-8f24b7dbcbd83311dad510863d8cb41f0e91b464.tar.bz2
bpo-42064: Convert `sqlite3` global state to module state (GH-29073)
Diffstat (limited to 'Modules/_sqlite/module.c')
-rw-r--r--Modules/_sqlite/module.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/Modules/_sqlite/module.c b/Modules/_sqlite/module.c
index 47b1f7a..e41ac0f 100644
--- a/Modules/_sqlite/module.c
+++ b/Modules/_sqlite/module.c
@@ -32,7 +32,7 @@
#error "SQLite 3.7.15 or higher required"
#endif
-#define clinic_state() (pysqlite_get_state(NULL))
+#define clinic_state() (pysqlite_get_state(module))
#include "clinic/module.c.h"
#undef clinic_state
@@ -41,8 +41,6 @@ module _sqlite3
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=81e330492d57488e]*/
-pysqlite_state pysqlite_global_state;
-
// NOTE: This must equal sqlite3.Connection.__init__ argument spec!
/*[clinic input]
_sqlite3.connect as pysqlite_connect
@@ -160,7 +158,7 @@ pysqlite_register_adapter_impl(PyObject *module, PyTypeObject *type,
pysqlite_state *state = pysqlite_get_state(module);
PyObject *protocol = (PyObject *)state->PrepareProtocolType;
- rc = pysqlite_microprotocols_add(type, protocol, caster);
+ rc = pysqlite_microprotocols_add(state, type, protocol, caster);
if (rc == -1) {
return NULL;
}
@@ -395,16 +393,11 @@ static int add_integer_constants(PyObject *module) {
return ret;
}
-static struct PyModuleDef _sqlite3module = {
- PyModuleDef_HEAD_INIT,
- "_sqlite3",
- NULL,
- -1,
- module_methods,
- NULL,
- NULL,
- NULL,
- NULL
+struct PyModuleDef _sqlite3module = {
+ .m_base = PyModuleDef_HEAD_INIT,
+ .m_name = "_sqlite3",
+ .m_size = sizeof(pysqlite_state),
+ .m_methods = module_methods,
};
#define ADD_TYPE(module, type) \