Skip to content

Commit 51ad4c9

Browse files
committed
check Py_None for fetch_all()
1 parent 62cb099 commit 51ad4c9

1 file changed

Lines changed: 30 additions & 26 deletions

File tree

src/gstype_python.i

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,37 +1264,41 @@ static bool convertToFieldWithType(GSRow *row, int column, PyObject* value, GSTy
12641264
*/
12651265
%typemap(in) (GSQuery* const* queryList, size_t queryCount)
12661266
(PyObject* pyQuery, std::shared_ptr<griddb::Query> query, void *vquery, int i, int res = 0) {
1267-
if (!PyList_Check($input)) {
1267+
if ($input == Py_None) {
1268+
$1 = NULL;
1269+
$2 = 0;
1270+
} else if (!PyList_Check($input)) {
12681271
PyErr_SetString(PyExc_ValueError, "Expected a List");
12691272
SWIG_fail;
1270-
}
1271-
$2 = (size_t)PyInt_AsLong(PyLong_FromSsize_t(PyList_Size($input)));
1272-
$1 = NULL;
1273-
i = 0;
1274-
if ($2 > 0) {
1275-
$1 = (GSQuery**) malloc($2 * sizeof(GSQuery*));
1276-
if ($1 == NULL) {
1277-
PyErr_SetString(PyExc_ValueError, "Memory allocation error");
1278-
SWIG_fail;
1279-
}
1280-
while (i < $2) {
1281-
pyQuery = PyList_GetItem($input,i);
1282-
{
1283-
int newmem = 0;
1284-
res = SWIG_ConvertPtrAndOwn(pyQuery, (void **) &vquery, $descriptor(std::shared_ptr<griddb::Query>*), %convertptr_flags, &newmem);
1285-
if (!SWIG_IsOK(res)) {
1286-
%argument_fail(res, "$type", $symname, $argnum);
1287-
}
1288-
if (vquery) {
1289-
query = *%reinterpret_cast(vquery, std::shared_ptr<griddb::Query>*);
1290-
$1[i] = query->gs_ptr();
1291-
if (newmem & SWIG_CAST_NEW_MEMORY) {
1292-
delete %reinterpret_cast(vquery, std::shared_ptr<griddb::Query>*);
1273+
} else {
1274+
$2 = (size_t)PyInt_AsLong(PyLong_FromSsize_t(PyList_Size($input)));
1275+
$1 = NULL;
1276+
i = 0;
1277+
if ($2 > 0) {
1278+
$1 = (GSQuery**) malloc($2 * sizeof(GSQuery*));
1279+
if ($1 == NULL) {
1280+
PyErr_SetString(PyExc_ValueError, "Memory allocation error");
1281+
SWIG_fail;
1282+
}
1283+
while (i < $2) {
1284+
pyQuery = PyList_GetItem($input,i);
1285+
{
1286+
int newmem = 0;
1287+
res = SWIG_ConvertPtrAndOwn(pyQuery, (void **) &vquery, $descriptor(std::shared_ptr<griddb::Query>*), %convertptr_flags, &newmem);
1288+
if (!SWIG_IsOK(res)) {
1289+
%argument_fail(res, "$type", $symname, $argnum);
1290+
}
1291+
if (vquery) {
1292+
query = *%reinterpret_cast(vquery, std::shared_ptr<griddb::Query>*);
1293+
$1[i] = query->gs_ptr();
1294+
if (newmem & SWIG_CAST_NEW_MEMORY) {
1295+
delete %reinterpret_cast(vquery, std::shared_ptr<griddb::Query>*);
1296+
}
12931297
}
12941298
}
1299+
1300+
i++;
12951301
}
1296-
1297-
i++;
12981302
}
12991303
}
13001304
}

0 commit comments

Comments
 (0)