@@ -30,54 +30,33 @@ int pysqlite_prepare_protocol_init(pysqlite_PrepareProtocol* self, PyObject* arg
3030
3131void pysqlite_prepare_protocol_dealloc (pysqlite_PrepareProtocol * self )
3232{
33- Py_TYPE (self )-> tp_free ((PyObject * )self );
33+ PyTypeObject * tp = Py_TYPE (self );
34+
35+ tp -> tp_free (self );
36+ Py_DECREF (tp );
3437}
3538
36- PyTypeObject pysqlite_PrepareProtocolType = {
37- PyVarObject_HEAD_INIT (NULL , 0 )
38- MODULE_NAME ".PrepareProtocol" , /* tp_name */
39- sizeof (pysqlite_PrepareProtocol ), /* tp_basicsize */
40- 0 , /* tp_itemsize */
41- (destructor )pysqlite_prepare_protocol_dealloc , /* tp_dealloc */
42- 0 , /* tp_vectorcall_offset */
43- 0 , /* tp_getattr */
44- 0 , /* tp_setattr */
45- 0 , /* tp_as_async */
46- 0 , /* tp_repr */
47- 0 , /* tp_as_number */
48- 0 , /* tp_as_sequence */
49- 0 , /* tp_as_mapping */
50- 0 , /* tp_hash */
51- 0 , /* tp_call */
52- 0 , /* tp_str */
53- 0 , /* tp_getattro */
54- 0 , /* tp_setattro */
55- 0 , /* tp_as_buffer */
56- Py_TPFLAGS_DEFAULT , /* tp_flags */
57- 0 , /* tp_doc */
58- 0 , /* tp_traverse */
59- 0 , /* tp_clear */
60- 0 , /* tp_richcompare */
61- 0 , /* tp_weaklistoffset */
62- 0 , /* tp_iter */
63- 0 , /* tp_iternext */
64- 0 , /* tp_methods */
65- 0 , /* tp_members */
66- 0 , /* tp_getset */
67- 0 , /* tp_base */
68- 0 , /* tp_dict */
69- 0 , /* tp_descr_get */
70- 0 , /* tp_descr_set */
71- 0 , /* tp_dictoffset */
72- (initproc )pysqlite_prepare_protocol_init , /* tp_init */
73- 0 , /* tp_alloc */
74- 0 , /* tp_new */
75- 0 /* tp_free */
39+ static PyType_Slot type_slots [] = {
40+ {Py_tp_dealloc , pysqlite_prepare_protocol_dealloc },
41+ {Py_tp_new , PyType_GenericNew },
42+ {Py_tp_init , pysqlite_prepare_protocol_init },
43+ {0 , NULL },
44+ };
45+
46+ static PyType_Spec type_spec = {
47+ .name = MODULE_NAME ".PrepareProtocol" ,
48+ .basicsize = sizeof (pysqlite_PrepareProtocol ),
49+ .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE ,
50+ .slots = type_slots ,
7651};
7752
78- extern int pysqlite_prepare_protocol_setup_types (void )
53+ PyTypeObject * pysqlite_PrepareProtocolType = NULL ;
54+
55+ extern int pysqlite_prepare_protocol_setup_types (PyObject * module )
7956{
80- pysqlite_PrepareProtocolType .tp_new = PyType_GenericNew ;
81- Py_SET_TYPE (& pysqlite_PrepareProtocolType , & PyType_Type );
82- return PyType_Ready (& pysqlite_PrepareProtocolType );
57+ pysqlite_PrepareProtocolType = (PyTypeObject * )PyType_FromModuleAndSpec (module , & type_spec , NULL );
58+ if (pysqlite_PrepareProtocolType == NULL ) {
59+ return -1 ;
60+ }
61+ return 0 ;
8362}
0 commit comments