@@ -69,6 +69,7 @@ static PyObject *
69
69
MrdbCursor_readresponse (MrdbCursor * self );
70
70
71
71
PyObject * MrdbCursor_clear_result (MrdbCursor * self );
72
+ static void ma_cursor_close (MrdbCursor * self );
72
73
73
74
void
74
75
field_fetch_callback (void * data , unsigned int column , unsigned char * * row );
@@ -346,20 +347,28 @@ static PyObject *MrdbCursor_repr(MrdbCursor *self)
346
347
return PyUnicode_FromString (cobj_repr );
347
348
}
348
349
350
+ static void MrdbCursor_dealloc (PyObject * obj )
351
+ {
352
+ MrdbCursor * self = (MrdbCursor * )obj ;
353
+ ma_cursor_close (self );
354
+ Py_TYPE (self )-> tp_free ((PyObject * )self );
355
+ }
356
+
349
357
PyTypeObject MrdbCursor_Type =
350
358
{
351
359
PyVarObject_HEAD_INIT (NULL , 0 )
352
360
.tp_name = "mariadb.cursor" ,
353
361
.tp_basicsize = (Py_ssize_t )sizeof (MrdbCursor ),
354
- .tp_repr = (reprfunc )MrdbCursor_repr ,
362
+ .tp_repr = (reprfunc )MrdbCursor_repr ,
355
363
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE ,
356
- .tp_doc = mariadb_cursor_documentation ,
364
+ .tp_doc = mariadb_cursor_documentation ,
357
365
.tp_traverse = (traverseproc )MrdbCursor_traverse ,/* tp_traverse */
358
366
.tp_methods = (struct PyMethodDef * )MrdbCursor_Methods ,
359
367
.tp_members = (struct PyMemberDef * )MrdbCursor_Members ,
360
368
.tp_getset = MrdbCursor_sets ,
361
369
.tp_init = (initproc )MrdbCursor_initialize ,
362
370
.tp_new = PyType_GenericNew ,
371
+ .tp_dealloc = MrdbCursor_dealloc ,
363
372
.tp_finalize = (destructor )MrdbCursor_finalize
364
373
};
365
374
0 commit comments