diff options
author | Peter Eisentraut | 2025-02-26 20:58:38 +0000 |
---|---|---|
committer | Peter Eisentraut | 2025-02-26 20:58:38 +0000 |
commit | f734c9fc3a91959c2473a1e33fd9b60116902175 (patch) | |
tree | a6f1530407f30ac7f92cd96e4bc174cc4a1da7c7 /src/pl/plpython/plpy_subxactobject.c | |
parent | 945a9e3832c3ede20e2c575b796a4f16687a1949 (diff) |
Revert "Prepare for Python "Limited API" in PL/Python"
This reverts commit c47e8df815c1c45f4e4fc90d5817d67ab088279f.
That commit makes the plpython tests crash with Python 3.6.* and
3.7.*. It will need further investigation and testing, so revert for
now.
Diffstat (limited to 'src/pl/plpython/plpy_subxactobject.c')
-rw-r--r-- | src/pl/plpython/plpy_subxactobject.c | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/src/pl/plpython/plpy_subxactobject.c b/src/pl/plpython/plpy_subxactobject.c index cc7ff3f9df7..5c92a0e089a 100644 --- a/src/pl/plpython/plpy_subxactobject.c +++ b/src/pl/plpython/plpy_subxactobject.c @@ -15,6 +15,7 @@ List *explicit_subtransactions = NIL; +static void PLy_subtransaction_dealloc(PyObject *subxact); static PyObject *PLy_subtransaction_enter(PyObject *self, PyObject *unused); static PyObject *PLy_subtransaction_exit(PyObject *self, PyObject *args); @@ -30,35 +31,21 @@ static PyMethodDef PLy_subtransaction_methods[] = { {NULL, NULL, 0, NULL} }; -static PyType_Slot PLySubtransaction_slots[] = -{ - { - Py_tp_doc, (char *) PLy_subtransaction_doc - }, - { - Py_tp_methods, PLy_subtransaction_methods - }, - { - 0, NULL - } -}; - -static PyType_Spec PLySubtransaction_spec = -{ - .name = "PLySubtransaction", - .basicsize = sizeof(PLySubtransactionObject), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - .slots = PLySubtransaction_slots, +static PyTypeObject PLy_SubtransactionType = { + PyVarObject_HEAD_INIT(NULL, 0) + .tp_name = "PLySubtransaction", + .tp_basicsize = sizeof(PLySubtransactionObject), + .tp_dealloc = PLy_subtransaction_dealloc, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + .tp_doc = PLy_subtransaction_doc, + .tp_methods = PLy_subtransaction_methods, }; -static PyTypeObject *PLy_SubtransactionType; - void PLy_subtransaction_init_type(void) { - PLy_SubtransactionType = (PyTypeObject *) PyType_FromSpec(&PLySubtransaction_spec); - if (!PLy_SubtransactionType) + if (PyType_Ready(&PLy_SubtransactionType) < 0) elog(ERROR, "could not initialize PLy_SubtransactionType"); } @@ -68,7 +55,7 @@ PLy_subtransaction_new(PyObject *self, PyObject *unused) { PLySubtransactionObject *ob; - ob = PyObject_New(PLySubtransactionObject, PLy_SubtransactionType); + ob = PyObject_New(PLySubtransactionObject, &PLy_SubtransactionType); if (ob == NULL) return NULL; @@ -79,6 +66,12 @@ PLy_subtransaction_new(PyObject *self, PyObject *unused) return (PyObject *) ob; } +/* Python requires a dealloc function to be defined */ +static void +PLy_subtransaction_dealloc(PyObject *subxact) +{ +} + /* * subxact.__enter__() or subxact.enter() * |