diff --git a/NEWS b/NEWS index ca91abef..1ca96e6d 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,10 @@ +What's new in psycopg 2.4.5 +--------------------------- + + - Fixed fetchmany() with no argument in cursor subclasses + (ticket #84). + + What's new in psycopg 2.4.4 --------------------------- diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c index 357b1a0b..bb9db691 100644 --- a/psycopg/cursor_type.c +++ b/psycopg/cursor_type.c @@ -850,13 +850,23 @@ psyco_curs_fetchmany(cursorObject *self, PyObject *args, PyObject *kwords) int i; PyObject *list, *res; + PyObject *pysize = NULL; long int size = self->arraysize; static char *kwlist[] = {"size", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwords, "|l", kwlist, &size)) { + /* allow passing None instead of omitting the *size* argument, + * or using the method from subclasses would be a problem */ + if (!PyArg_ParseTupleAndKeywords(args, kwords, "|O", kwlist, &pysize)) { return NULL; } + if (pysize && pysize != Py_None) { + size = PyInt_AsLong(pysize); + if (size == -1 && PyErr_Occurred()) { + return NULL; + } + } + EXC_IF_CURS_CLOSED(self); if (_psyco_curs_prefetch(self) < 0) return NULL; EXC_IF_NO_TUPLES(self);