diff --git a/psycopg/adapter_asis.c b/psycopg/adapter_asis.c index d64b1410..e11caa04 100644 --- a/psycopg/adapter_asis.c +++ b/psycopg/adapter_asis.c @@ -108,7 +108,7 @@ asis_setup(asisObject *self, PyObject *obj) ); Py_INCREF(obj); - self->wrapped = obj; + self->wrapped = TO_STATE(obj); Dprintf("asis_setup: good asis object at %p, refcnt = " FORMAT_CODE_PY_SSIZE_T, diff --git a/psycopg/adapter_binary.c b/psycopg/adapter_binary.c index 1727b19a..fa95906c 100644 --- a/psycopg/adapter_binary.c +++ b/psycopg/adapter_binary.c @@ -133,7 +133,7 @@ static PyObject * binary_getquoted(binaryObject *self, PyObject *args) { if (self->buffer == NULL) { - self->buffer = binary_quote(self); + self->buffer = TO_STATE(binary_quote(self)); } Py_XINCREF(self->buffer); return self->buffer; @@ -210,7 +210,7 @@ binary_setup(binaryObject *self, PyObject *str) self->buffer = NULL; self->conn = NULL; Py_INCREF(str); - self->wrapped = str; + self->wrapped = TO_STATE(str); Dprintf("binary_setup: good binary object at %p, refcnt = " FORMAT_CODE_PY_SSIZE_T, diff --git a/psycopg/adapter_datetime.c b/psycopg/adapter_datetime.c index b201ae27..b701d0fa 100644 --- a/psycopg/adapter_datetime.c +++ b/psycopg/adapter_datetime.c @@ -177,7 +177,7 @@ pydatetime_setup(pydatetimeObject *self, PyObject *obj, int type) self->type = type; Py_INCREF(obj); - self->wrapped = obj; + self->wrapped = TO_STATE(obj); Dprintf("pydatetime_setup: good pydatetime object at %p, refcnt = " FORMAT_CODE_PY_SSIZE_T, diff --git a/psycopg/adapter_list.c b/psycopg/adapter_list.c index 889c5f84..1db42c50 100644 --- a/psycopg/adapter_list.c +++ b/psycopg/adapter_list.c @@ -240,7 +240,7 @@ list_setup(listObject *self, PyObject *obj) self->connection = NULL; Py_INCREF(obj); - self->wrapped = obj; + self->wrapped = TO_STATE(obj); Dprintf("list_setup: good list object at %p, refcnt = " FORMAT_CODE_PY_SSIZE_T, diff --git a/psycopg/adapter_mxdatetime.c b/psycopg/adapter_mxdatetime.c index 94642df5..f80cdea2 100644 --- a/psycopg/adapter_mxdatetime.c +++ b/psycopg/adapter_mxdatetime.c @@ -163,7 +163,7 @@ mxdatetime_setup(mxdatetimeObject *self, PyObject *obj, int type) self->type = type; Py_INCREF(obj); - self->wrapped = obj; + self->wrapped = TO_STATE(obj); Dprintf("mxdatetime_setup: good mxdatetime object at %p, refcnt = " FORMAT_CODE_PY_SSIZE_T, diff --git a/psycopg/adapter_pboolean.c b/psycopg/adapter_pboolean.c index c7e3b807..bef35f46 100644 --- a/psycopg/adapter_pboolean.c +++ b/psycopg/adapter_pboolean.c @@ -96,7 +96,7 @@ pboolean_setup(pbooleanObject *self, PyObject *obj) ); Py_INCREF(obj); - self->wrapped = obj; + self->wrapped = TO_STATE(obj); Dprintf("pboolean_setup: good pboolean object at %p, refcnt = " FORMAT_CODE_PY_SSIZE_T, diff --git a/psycopg/adapter_pdecimal.c b/psycopg/adapter_pdecimal.c index fcff9d20..70f37a3d 100644 --- a/psycopg/adapter_pdecimal.c +++ b/psycopg/adapter_pdecimal.c @@ -161,7 +161,7 @@ pdecimal_setup(pdecimalObject *self, PyObject *obj) ); Py_INCREF(obj); - self->wrapped = obj; + self->wrapped = TO_STATE(obj); Dprintf("pdecimal_setup: good pdecimal object at %p, refcnt = " FORMAT_CODE_PY_SSIZE_T, diff --git a/psycopg/adapter_pfloat.c b/psycopg/adapter_pfloat.c index c33ccae7..60dff19b 100644 --- a/psycopg/adapter_pfloat.c +++ b/psycopg/adapter_pfloat.c @@ -35,6 +35,7 @@ /** the Float object **/ +IGNORE_REFCOUNT /* bug davidmalcolm/gcc-python-plugin#165 */ static PyObject * pfloat_getquoted(pfloatObject *self, PyObject *args) { @@ -134,7 +135,7 @@ pfloat_setup(pfloatObject *self, PyObject *obj) ); Py_INCREF(obj); - self->wrapped = obj; + self->wrapped = TO_STATE(obj); Dprintf("pfloat_setup: good pfloat object at %p, refcnt = " FORMAT_CODE_PY_SSIZE_T, diff --git a/psycopg/adapter_pint.c b/psycopg/adapter_pint.c index 72bbdbfe..61ea0ff6 100644 --- a/psycopg/adapter_pint.c +++ b/psycopg/adapter_pint.c @@ -139,7 +139,7 @@ pint_setup(pintObject *self, PyObject *obj) ); Py_INCREF(obj); - self->wrapped = obj; + self->wrapped = TO_STATE(obj); Dprintf("pint_setup: good pint object at %p, refcnt = " FORMAT_CODE_PY_SSIZE_T, diff --git a/psycopg/adapter_qstring.c b/psycopg/adapter_qstring.c index 0a4e7e82..5de8c5c3 100644 --- a/psycopg/adapter_qstring.c +++ b/psycopg/adapter_qstring.c @@ -74,6 +74,7 @@ qstring_quote(qstringObject *self) /* encode the string into buffer */ Bytes_AsStringAndSize(str, &s, &len); if (!(buffer = psycopg_escape_string(self->conn, s, len, NULL, &qlen))) { + FAKE_RAISE(); goto exit; } @@ -98,7 +99,7 @@ static PyObject * qstring_getquoted(qstringObject *self, PyObject *args) { if (self->buffer == NULL) { - self->buffer = qstring_quote(self); + self->buffer = TO_STATE(qstring_quote(self)); } Py_XINCREF(self->buffer); return self->buffer; @@ -215,7 +216,7 @@ qstring_setup(qstringObject *self, PyObject *str) ); Py_INCREF(str); - self->wrapped = str; + self->wrapped = TO_STATE(str); Dprintf("qstring_setup: good qstring object at %p, refcnt = " FORMAT_CODE_PY_SSIZE_T, diff --git a/psycopg/microprotocols_proto.c b/psycopg/microprotocols_proto.c index dfbf8e3c..d976d2af 100644 --- a/psycopg/microprotocols_proto.c +++ b/psycopg/microprotocols_proto.c @@ -99,8 +99,8 @@ static struct PyMemberDef isqlquoteObject_members[] = { static int isqlquote_setup(isqlquoteObject *self, PyObject *wrapped) { - self->wrapped = wrapped; Py_INCREF(wrapped); + self->wrapped = TO_STATE(wrapped); return 0; }