Py_INCREF(parent);
self->parent = parent;
- if (!PyTuple_CheckExact(row)) {
- PyErr_SetString(PyExc_TypeError, "row must be a tuple");
+ if (!PySequence_Check(row)) {
+ PyErr_SetString(PyExc_TypeError, "row must be a sequence");
return -1;
}
Py_INCREF(row);
{
Py_ssize_t num_values, num_processors;
PyObject **valueptr, **funcptr, **resultptr;
- PyObject *func, *result, *processed_value;
+ PyObject *func, *result, *processed_value, *values_fastseq;
num_values = Py_SIZE(values);
num_processors = Py_SIZE(processors);
if (num_values != num_processors) {
- PyErr_SetString(PyExc_RuntimeError,
- "number of values in row differ from number of column processors");
+ PyErr_Format(PyExc_RuntimeError,
+ "number of values in row (%d) differ from number of column "
+ "processors (%d)",
+ num_values, num_processors);
return NULL;
}
if (result == NULL)
return NULL;
- /* we don't need to use PySequence_Fast as long as values, processors and
- * result are simple tuple or lists. */
- valueptr = PySequence_Fast_ITEMS(values);
+ values_fastseq = PySequence_Fast(values, "row must be a sequence");
+ if (values_fastseq == NULL)
+ return NULL;
+
+ valueptr = PySequence_Fast_ITEMS(values_fastseq);
funcptr = PySequence_Fast_ITEMS(processors);
resultptr = PySequence_Fast_ITEMS(result);
while (--num_values >= 0) {
processed_value = PyObject_CallFunctionObjArgs(func, *valueptr,
NULL);
if (processed_value == NULL) {
+ Py_DECREF(values_fastseq);
Py_DECREF(result);
return NULL;
}
funcptr++;
resultptr++;
}
+ Py_DECREF(values_fastseq);
return result;
}
self->processors, 0);
}
-static PyTupleObject *
-BaseRowProxy_tuplevalues(BaseRowProxy *self)
-{
- return (PyTupleObject *)BaseRowProxy_processvalues(self->row,
- self->processors, 1);
-}
-
static PyObject *
BaseRowProxy_iter(BaseRowProxy *self)
{
PyObject *values, *result;
- values = (PyObject *)BaseRowProxy_tuplevalues(self);
+ values = BaseRowProxy_processvalues(self->row, self->processors, 1);
if (values == NULL)
return NULL;
if (!PyTuple_CheckExact(value)) {
PyErr_SetString(PyExc_TypeError,
- "The 'row' attribute value must be a tuple");
+ "The 'row' attribute value must be a sequence");
return -1;
}