diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2021-06-15 12:47:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-15 12:47:34 (GMT) |
commit | 10a5c806d4dec6c342dcc9888fbe4fa1fa9b7a1f (patch) | |
tree | 8ed7c361bfa27d7b41bcab5a43c9ebc1957e7fd3 /Modules/_sqlite/cursor.c | |
parent | 8ebd9447e9618240ee3b955888d114376f64117b (diff) | |
download | cpython-10a5c806d4dec6c342dcc9888fbe4fa1fa9b7a1f.zip cpython-10a5c806d4dec6c342dcc9888fbe4fa1fa9b7a1f.tar.gz cpython-10a5c806d4dec6c342dcc9888fbe4fa1fa9b7a1f.tar.bz2 |
bpo-42064: Move sqlite3 types to global state (GH-26537)
* Move connection type to global state
* Move cursor type to global state
* Move prepare protocol type to global state
* Move row type to global state
* Move statement type to global state
* ADD_TYPE takes a pointer
* pysqlite_get_state is now static inline
Diffstat (limited to 'Modules/_sqlite/cursor.c')
-rw-r--r-- | Modules/_sqlite/cursor.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index c2e8de5..8c8a347 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -24,20 +24,23 @@ #include "cursor.h" #include "module.h" #include "util.h" + +#define clinic_state() (pysqlite_get_state(NULL)) #include "clinic/cursor.c.h" +#undef clinic_state /*[clinic input] module _sqlite3 -class _sqlite3.Cursor "pysqlite_Cursor *" "pysqlite_CursorType" +class _sqlite3.Cursor "pysqlite_Cursor *" "clinic_state()->CursorType" [clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b2072d8db95411d5]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=3c5b8115c5cf30f1]*/ static const char errmsg_fetch_across_rollback[] = "Cursor needed to be reset because of commit/rollback and can no longer be fetched from."; /*[clinic input] _sqlite3.Cursor.__init__ as pysqlite_cursor_init - connection: object(type='pysqlite_Connection *', subclass_of='pysqlite_ConnectionType') + connection: object(type='pysqlite_Connection *', subclass_of='clinic_state()->ConnectionType') / [clinic start generated code]*/ @@ -45,7 +48,7 @@ _sqlite3.Cursor.__init__ as pysqlite_cursor_init static int pysqlite_cursor_init_impl(pysqlite_Cursor *self, pysqlite_Connection *connection) -/*[clinic end generated code: output=ac59dce49a809ca8 input=a8a4f75ac90999b2]*/ +/*[clinic end generated code: output=ac59dce49a809ca8 input=23d4265b534989fb]*/ { Py_INCREF(connection); Py_XSETREF(self->connection, connection); @@ -1079,14 +1082,14 @@ static PyType_Spec cursor_spec = { .slots = cursor_slots, }; -PyTypeObject *pysqlite_CursorType = NULL; - int pysqlite_cursor_setup_types(PyObject *module) { - pysqlite_CursorType = (PyTypeObject *)PyType_FromModuleAndSpec(module, &cursor_spec, NULL); - if (pysqlite_CursorType == NULL) { + PyObject *type = PyType_FromModuleAndSpec(module, &cursor_spec, NULL); + if (type == NULL) { return -1; } + pysqlite_state *state = pysqlite_get_state(module); + state->CursorType = (PyTypeObject *)type; return 0; } |