mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-29 04:13:43 +03:00
fetchmany accepts None as size, meaning the default arraysize
without this care, extending fetchmany in subclasses becomes tricky. Closes ticket #84.
This commit is contained in:
parent
09a8e7bf1f
commit
dcc60131a9
7
NEWS
7
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
|
What's new in psycopg 2.4.4
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
|
|
|
@ -850,13 +850,23 @@ psyco_curs_fetchmany(cursorObject *self, PyObject *args, PyObject *kwords)
|
||||||
int i;
|
int i;
|
||||||
PyObject *list, *res;
|
PyObject *list, *res;
|
||||||
|
|
||||||
|
PyObject *pysize = NULL;
|
||||||
long int size = self->arraysize;
|
long int size = self->arraysize;
|
||||||
static char *kwlist[] = {"size", NULL};
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pysize && pysize != Py_None) {
|
||||||
|
size = PyInt_AsLong(pysize);
|
||||||
|
if (size == -1 && PyErr_Occurred()) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EXC_IF_CURS_CLOSED(self);
|
EXC_IF_CURS_CLOSED(self);
|
||||||
if (_psyco_curs_prefetch(self) < 0) return NULL;
|
if (_psyco_curs_prefetch(self) < 0) return NULL;
|
||||||
EXC_IF_NO_TUPLES(self);
|
EXC_IF_NO_TUPLES(self);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user