diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2012-03-04 17:59:51 +0000 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2012-03-04 17:59:51 +0000 |
| commit | 0e832b97ea7a84220f2148db3746e10f85eadef2 (patch) | |
| tree | 747b74dfaa8bc058227ce56b965d14aad28bcf15 /psycopg/adapter_qstring.c | |
| parent | 76cc838a93dc2e55c6ddd101a543bda61cba4550 (diff) | |
| download | psycopg2-0e832b97ea7a84220f2148db3746e10f85eadef2.tar.gz | |
Proper type check in prepare() methods for list, binary, qstring
Diffstat (limited to 'psycopg/adapter_qstring.c')
| -rw-r--r-- | psycopg/adapter_qstring.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/psycopg/adapter_qstring.c b/psycopg/adapter_qstring.c index 4240d38..773cfa0 100644 --- a/psycopg/adapter_qstring.c +++ b/psycopg/adapter_qstring.c @@ -124,24 +124,22 @@ qstring_str(qstringObject *self) static PyObject * qstring_prepare(qstringObject *self, PyObject *args) { - connectionObject *conn; + PyObject *conn; - if (!PyArg_ParseTuple(args, "O", &conn)) + if (!PyArg_ParseTuple(args, "O!", &connectionType, &conn)) return NULL; /* we bother copying the encoding only if the wrapped string is unicode, we don't need the encoding if that's not the case */ if (PyUnicode_Check(self->wrapped)) { if (self->encoding) free(self->encoding); - self->encoding = strdup(conn->codec); - Dprintf("qstring_prepare: set encoding to %s", conn->codec); + self->encoding = strdup(((connectionObject *)conn)->codec); + Dprintf("qstring_prepare: set encoding to %s", self->encoding); } Py_CLEAR(self->conn); - if (conn) { - Py_INCREF(conn); - self->conn = (PyObject*)conn; - } + Py_INCREF(conn); + self->conn = conn; Py_INCREF(Py_None); return Py_None; |
