summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/module.c
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2021-07-20 10:59:18 (GMT)
committerGitHub <noreply@github.com>2021-07-20 10:59:18 (GMT)
commit4c0deb25ac899fbe4da626ce3cb21f204cdd3aa9 (patch)
tree4f2aa2801e9981d143d1f9a5dd543f2ea8579859 /Modules/_sqlite/module.c
parent366fcbac18e3adc41e3901580dbedb6a91e41a10 (diff)
downloadcpython-4c0deb25ac899fbe4da626ce3cb21f204cdd3aa9.zip
cpython-4c0deb25ac899fbe4da626ce3cb21f204cdd3aa9.tar.gz
cpython-4c0deb25ac899fbe4da626ce3cb21f204cdd3aa9.tar.bz2
bpo-42064: Finalise establishing sqlite3 global state (GH-27155)
With this, all sqlite3 static globals have been moved to the global state. There are a couple of global static strings left, but there should be no need for adding them to the state. https://bugs.python.org/issue42064
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 3d81ad8..98b2c90 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