File: rrdtoolmodule.c
Function: PyRRD_fetch
Error: returning (PyObject*)NULL without setting an exception
193 static PyObject *PyRRD_fetch(
194     PyObject UNUSED(*self),
195     PyObject * args)
196 {
197     PyObject *r;
198     rrd_value_t *data, *datai;
199     unsigned long step, ds_cnt;
200     time_t    start, end;
201     int       argc;
202     char    **argv, **ds_namv;
203 
204     if (create_args("fetch", args, &argc, &argv) < 0)
205         return NULL;
when considering range: -0x80000000 <= value <= -1
taking True path
206 
207     if (rrd_fetch(argc, argv, &start, &end, &step,
208                   &ds_cnt, &ds_namv, &data) == -1) {
209         PyErr_SetString(ErrorObject, rrd_get_error());
210         rrd_clear_error();
211         r = NULL;
212     } else {
213         /* Return :
214            ((start, end, step), (name1, name2, ...), [(data1, data2, ..), ...]) */
215         PyObject *range_tup, *dsnam_tup, *data_list, *t;
216         unsigned long i, j, row;
217         rrd_value_t dv;
218 
219         row = (end - start) / step;
220 
221         r = PyTuple_New(3);
222         range_tup = PyTuple_New(3);
223         dsnam_tup = PyTuple_New(ds_cnt);
224         data_list = PyList_New(row);
225         PyTuple_SET_ITEM(r, 0, range_tup);
226         PyTuple_SET_ITEM(r, 1, dsnam_tup);
227         PyTuple_SET_ITEM(r, 2, data_list);
228 
229         datai = data;
230 
231         PyTuple_SET_ITEM(range_tup, 0, PyInt_FromLong((long) start));
232         PyTuple_SET_ITEM(range_tup, 1, PyInt_FromLong((long) end));
233         PyTuple_SET_ITEM(range_tup, 2, PyInt_FromLong((long) step));
234 
235         for (i = 0; i < ds_cnt; i++)
236             PyTuple_SET_ITEM(dsnam_tup, i, PyString_FromString(ds_namv[i]));
237 
238         for (i = 0; i < row; i++) {
239             t = PyTuple_New(ds_cnt);
240             PyList_SET_ITEM(data_list, i, t);
241 
242             for (j = 0; j < ds_cnt; j++) {
243                 dv = *(datai++);
244                 if (isnan(dv)) {
245                     PyTuple_SET_ITEM(t, j, Py_None);
246                     Py_INCREF(Py_None);
247                 } else {
248                     PyTuple_SET_ITEM(t, j, PyFloat_FromDouble((double) dv));
249                 }
250             }
251         }
252 
253         for (i = 0; i < ds_cnt; i++)
254             rrd_freemem(ds_namv[i]);
255         rrd_freemem(ds_namv);   /* rrdtool don't use PyMem_Malloc :) */
256         rrd_freemem(data);
257     }
258 
259     destroy_args(&argv);
260     return r;
261 }
262 
returning (PyObject*)NULL without setting an exception