diff --git a/psycopg/typecast_array.c b/psycopg/typecast_array.c index 9cec95c0..a5a718ca 100644 --- a/psycopg/typecast_array.c +++ b/psycopg/typecast_array.c @@ -56,7 +56,7 @@ typecast_array_cleanup(const char **str, Py_ssize_t *len) #define ASCAN_TOKEN 3 #define ASCAN_QUOTED 4 -static int +RAISES_NEG static int typecast_array_tokenize(const char *str, Py_ssize_t strlength, Py_ssize_t *pos, char** token, Py_ssize_t *length, int *quotes) @@ -202,7 +202,8 @@ typecast_array_scan(const char *str, Py_ssize_t strlength, if (obj == NULL) return -1; PyList_Append(array, obj); - Py_DECREF(obj); + TO_STATE(obj); + Py_CLEAR(obj); } else if (state == ASCAN_BEGIN) { diff --git a/psycopg/typecast_binary.c b/psycopg/typecast_binary.c index 3d09784f..795a9123 100644 --- a/psycopg/typecast_binary.c +++ b/psycopg/typecast_binary.c @@ -155,6 +155,7 @@ typecast_BINARY_cast(const char *s, Py_ssize_t l, PyObject *curs) * an easy format. */ if (NULL == (buffer = psycopg_parse_hex(s, l, &len))) { + FAKE_RAISE(); /* issue davidmalcolm/gcc-python-plugin#75 */ goto exit; } } @@ -170,6 +171,7 @@ typecast_BINARY_cast(const char *s, Py_ssize_t l, PyObject *curs) * story. */ if (NULL == (buffer = psycopg_parse_escape(s, l, &len))) { + FAKE_RAISE(); /* issue davidmalcolm/gcc-python-plugin#75 */ goto exit; } } diff --git a/psycopg/xid_type.c b/psycopg/xid_type.c index ab6c33e2..4c1862fb 100644 --- a/psycopg/xid_type.c +++ b/psycopg/xid_type.c @@ -131,12 +131,12 @@ xid_init(xidObject *self, PyObject *args, PyObject *kwargs) } } - if (!(self->format_id = PyInt_FromLong(format_id))) { return -1; } - if (!(self->gtrid = Text_FromUTF8(gtrid))) { return -1; } - if (!(self->bqual = Text_FromUTF8(bqual))) { return -1; } - Py_INCREF(Py_None); self->prepared = Py_None; - Py_INCREF(Py_None); self->owner = Py_None; - Py_INCREF(Py_None); self->database = Py_None; + if (!(self->format_id = TO_STATE(PyInt_FromLong(format_id)))) { return -1; } + if (!(self->gtrid = TO_STATE(Text_FromUTF8(gtrid)))) { return -1; } + if (!(self->bqual = TO_STATE(Text_FromUTF8(bqual)))) { return -1; } + Py_INCREF(Py_None); self->prepared = TO_STATE(Py_None); + Py_INCREF(Py_None); self->owner = TO_STATE(Py_None); + Py_INCREF(Py_None); self->database = TO_STATE(Py_None); return 0; }