From b8c8cddc2d885921c8ec067615707a187f7f9032 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Tue, 4 Jan 2011 02:10:28 +0100 Subject: [PATCH] Fixed argument parsing in lobject.read Using an int instead of a Py_ssize_t randomly crashed Python 3.1 64 bit. --- psycopg/lobject_type.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/psycopg/lobject_type.c b/psycopg/lobject_type.c index 0feffbcb..9a5fb0b8 100644 --- a/psycopg/lobject_type.c +++ b/psycopg/lobject_type.c @@ -71,7 +71,8 @@ psyco_lobj_close(lobjectObject *self, PyObject *args) static PyObject * psyco_lobj_write(lobjectObject *self, PyObject *args) { - int len, res=0; + int res = 0; + Py_ssize_t len; const char *buffer; if (!PyArg_ParseTuple(args, "s#", &buffer, &len)) return NULL; @@ -80,7 +81,7 @@ psyco_lobj_write(lobjectObject *self, PyObject *args) EXC_IF_LOBJ_LEVEL0(self); EXC_IF_LOBJ_UNMARKED(self); - if ((res = lobject_write(self, buffer, len)) < 0) return NULL; + if ((res = lobject_write(self, buffer, (size_t)len)) < 0) return NULL; return PyInt_FromLong((long)res); }