diff --git a/psycopg/adapter_qstring.c b/psycopg/adapter_qstring.c index 590ffea9..0a4e7e82 100644 --- a/psycopg/adapter_qstring.c +++ b/psycopg/adapter_qstring.c @@ -113,14 +113,14 @@ qstring_str(qstringObject *self) static PyObject * qstring_prepare(qstringObject *self, PyObject *args) { - connectionObject *conn; + PyObject *conn; if (!PyArg_ParseTuple(args, "O!", &connectionType, &conn)) return NULL; Py_CLEAR(self->conn); Py_INCREF(conn); - self->conn = conn; + self->conn = (connectionObject *)conn; Py_RETURN_NONE; } diff --git a/psycopg/replication_message_type.c b/psycopg/replication_message_type.c index b37c402e..6927cf66 100644 --- a/psycopg/replication_message_type.c +++ b/psycopg/replication_message_type.c @@ -58,12 +58,17 @@ replmsg_repr(replicationMessageObject *self) static int replmsg_init(PyObject *obj, PyObject *args, PyObject *kwargs) { - replicationMessageObject *self = (replicationMessageObject*) obj; + PyObject *cur = NULL; + replicationMessageObject *self = (replicationMessageObject *)obj; - if (!PyArg_ParseTuple(args, "O!O", &cursorType, &self->cursor, &self->payload)) + if (!PyArg_ParseTuple( + args, "O!O", &cursorType, &cur, &self->payload)) { return -1; - Py_XINCREF(self->cursor); - Py_XINCREF(self->payload); + } + + Py_INCREF(cur); + self->cursor = (cursorObject *)cur; + Py_INCREF(self->payload); self->data_size = 0; self->data_start = 0; @@ -76,7 +81,7 @@ replmsg_init(PyObject *obj, PyObject *args, PyObject *kwargs) static int replmsg_traverse(replicationMessageObject *self, visitproc visit, void *arg) { - Py_VISIT((PyObject* )self->cursor); + Py_VISIT((PyObject *)self->cursor); Py_VISIT(self->payload); return 0; }