Skip to content

Commit 123256e

Browse files
committed
Further cpychecker annotations
1 parent d89b3ed commit 123256e

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

psycopg/typecast_array.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ typecast_array_cleanup(const char **str, Py_ssize_t *len)
5656
#define ASCAN_TOKEN 3
5757
#define ASCAN_QUOTED 4
5858

59-
static int
59+
RAISES_NEG static int
6060
typecast_array_tokenize(const char *str, Py_ssize_t strlength,
6161
Py_ssize_t *pos, char** token,
6262
Py_ssize_t *length, int *quotes)
@@ -202,7 +202,8 @@ typecast_array_scan(const char *str, Py_ssize_t strlength,
202202
if (obj == NULL) return -1;
203203

204204
PyList_Append(array, obj);
205-
Py_DECREF(obj);
205+
TO_STATE(obj);
206+
Py_CLEAR(obj);
206207
}
207208

208209
else if (state == ASCAN_BEGIN) {

psycopg/typecast_binary.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ typecast_BINARY_cast(const char *s, Py_ssize_t l, PyObject *curs)
155155
* an easy format.
156156
*/
157157
if (NULL == (buffer = psycopg_parse_hex(s, l, &len))) {
158+
FAKE_RAISE(); /* issue davidmalcolm/gcc-python-plugin#75 */
158159
goto exit;
159160
}
160161
}
@@ -170,6 +171,7 @@ typecast_BINARY_cast(const char *s, Py_ssize_t l, PyObject *curs)
170171
* story.
171172
*/
172173
if (NULL == (buffer = psycopg_parse_escape(s, l, &len))) {
174+
FAKE_RAISE(); /* issue davidmalcolm/gcc-python-plugin#75 */
173175
goto exit;
174176
}
175177
}

psycopg/xid_type.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ xid_init(xidObject *self, PyObject *args, PyObject *kwargs)
131131
}
132132
}
133133

134-
if (!(self->format_id = PyInt_FromLong(format_id))) { return -1; }
135-
if (!(self->gtrid = Text_FromUTF8(gtrid))) { return -1; }
136-
if (!(self->bqual = Text_FromUTF8(bqual))) { return -1; }
137-
Py_INCREF(Py_None); self->prepared = Py_None;
138-
Py_INCREF(Py_None); self->owner = Py_None;
139-
Py_INCREF(Py_None); self->database = Py_None;
134+
if (!(self->format_id = TO_STATE(PyInt_FromLong(format_id)))) { return -1; }
135+
if (!(self->gtrid = TO_STATE(Text_FromUTF8(gtrid)))) { return -1; }
136+
if (!(self->bqual = TO_STATE(Text_FromUTF8(bqual)))) { return -1; }
137+
Py_INCREF(Py_None); self->prepared = TO_STATE(Py_None);
138+
Py_INCREF(Py_None); self->owner = TO_STATE(Py_None);
139+
Py_INCREF(Py_None); self->database = TO_STATE(Py_None);
140140

141141
return 0;
142142
}

0 commit comments

Comments
 (0)