Python module: fetchone/fetchmany return None/short list instead of exception at the end of the results
This commit is contained in:
parent
ad4365c40c
commit
4f4e8ff8f8
@ -1094,8 +1094,8 @@ Query_fetchone(PyObject *_self)
|
|||||||
// xapian result count estimate are sometimes wrong, we must go on
|
// xapian result count estimate are sometimes wrong, we must go on
|
||||||
// fetching until we fail
|
// fetching until we fail
|
||||||
if (!self->query->getDoc(self->next, *result->doc, self->fetchtext)) {
|
if (!self->query->getDoc(self->next, *result->doc, self->fetchtext)) {
|
||||||
PyErr_SetNone(PyExc_StopIteration);
|
Py_DECREF(result);
|
||||||
return 0;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
self->next++;
|
self->next++;
|
||||||
|
|
||||||
@ -1128,12 +1128,11 @@ Query_fetchmany(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int cnt = self->query->getResCnt();
|
int cnt = self->query->getResCnt();
|
||||||
|
PyObject *reslist = PyList_New(0);
|
||||||
if (cnt <= 0 || self->next < 0) {
|
if (cnt <= 0 || self->next < 0) {
|
||||||
PyErr_SetString(PyExc_AttributeError, "query: no results");
|
return (PyObject *)reslist;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *reslist = PyList_New(0);
|
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
recoll_DocObject *docobj = (recoll_DocObject *)
|
recoll_DocObject *docobj = (recoll_DocObject *)
|
||||||
PyObject_CallObject((PyObject *)&recoll_DocType, 0);
|
PyObject_CallObject((PyObject *)&recoll_DocType, 0);
|
||||||
@ -1142,7 +1141,7 @@ Query_fetchmany(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!self->query->getDoc(self->next, *docobj->doc, self->fetchtext)) {
|
if (!self->query->getDoc(self->next, *docobj->doc, self->fetchtext)) {
|
||||||
PyErr_SetNone(PyExc_StopIteration);
|
Py_DECREF(docobj);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
self->next++;
|
self->next++;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user