aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Modules/_sqlite/module.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_sqlite/module.c')
-rw-r--r--Modules/_sqlite/module.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/Modules/_sqlite/module.c b/Modules/_sqlite/module.c
index 3d81ad8f140..98b2c90108f 100644
--- a/Modules/_sqlite/module.c
+++ b/Modules/_sqlite/module.c
@@ -41,11 +41,6 @@ module _sqlite3
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=81e330492d57488e]*/
-/* static objects at module-level */
-PyObject* _pysqlite_converters = NULL;
-int _pysqlite_enable_callback_tracebacks = 0;
-int pysqlite_BaseTypeAdapted = 0;
-
pysqlite_state pysqlite_global_state;
// NOTE: This must equal sqlite3.Connection.__init__ argument spec!
@@ -159,7 +154,8 @@ pysqlite_register_adapter_impl(PyObject *module, PyTypeObject *type,
* (99 % of all usages) */
if (type == &PyLong_Type || type == &PyFloat_Type
|| type == &PyUnicode_Type || type == &PyByteArray_Type) {
- pysqlite_BaseTypeAdapted = 1;
+ pysqlite_state *state = pysqlite_get_state(module);
+ state->BaseTypeAdapted = 1;
}
pysqlite_state *state = pysqlite_get_state(NULL);
@@ -197,7 +193,8 @@ pysqlite_register_converter_impl(PyObject *module, PyObject *orig_name,
goto error;
}
- if (PyDict_SetItem(_pysqlite_converters, name, callable) != 0) {
+ pysqlite_state *state = pysqlite_get_state(module);
+ if (PyDict_SetItem(state->converters, name, callable) != 0) {
goto error;
}
@@ -220,7 +217,8 @@ static PyObject *
pysqlite_enable_callback_trace_impl(PyObject *module, int enable)
/*[clinic end generated code: output=4ff1d051c698f194 input=cb79d3581eb77c40]*/
{
- _pysqlite_enable_callback_tracebacks = enable;
+ pysqlite_state *state = pysqlite_get_state(module);
+ state->enable_callback_tracebacks = enable;
Py_RETURN_NONE;
}
@@ -246,15 +244,13 @@ pysqlite_adapt_impl(PyObject *module, PyObject *obj, PyObject *proto,
static int converters_init(PyObject* module)
{
- _pysqlite_converters = PyDict_New();
- if (!_pysqlite_converters) {
+ pysqlite_state *state = pysqlite_get_state(module);
+ state->converters = PyDict_New();
+ if (state->converters == NULL) {
return -1;
}
- int res = PyModule_AddObjectRef(module, "converters", _pysqlite_converters);
- Py_DECREF(_pysqlite_converters);
-
- return res;
+ return PyModule_AddObjectRef(module, "converters", state->converters);
}
static int