diff --git a/psycopg/error_type.c b/psycopg/error_type.c index 21b0c4ef..da3056b7 100644 --- a/psycopg/error_type.c +++ b/psycopg/error_type.c @@ -90,6 +90,8 @@ error_init(errorObject *self, PyObject *args, PyObject *kwargs) static int error_traverse(errorObject *self, visitproc visit, void *arg) { + Py_VISIT(self->pgerror); + Py_VISIT(self->pgcode); Py_VISIT(self->cursor); return ((PyTypeObject *)PyExc_StandardError)->tp_traverse( (PyObject *)self, visit, arg); @@ -101,8 +103,10 @@ error_clear(errorObject *self) Py_CLEAR(self->pgerror); Py_CLEAR(self->pgcode); Py_CLEAR(self->cursor); + PyMem_Free(self->codec); CLEARPGRES(self->pgres); + return ((PyTypeObject *)PyExc_StandardError)->tp_clear((PyObject *)self); }