File: bitarray/_bitarray.c
Function: bitarray_fromfile
Error: returning (PyObject*)NULL without setting an exception
1160 static PyObject *
1161 bitarray_fromfile(bitarrayobject *self, PyObject *args)
1162 {
1163     PyObject *f;
1164     FILE *fp;
1165     Py_ssize_t newsize, nbytes = -1;
1166     size_t nread;
1167     idx_t t, p;
1168     long cur;
1169 
1170     if (!PyArg_ParseTuple(args, "O|n:fromfile", &f, &nbytes))
when _PyArg_ParseTuple_SizeT() succeeds
taking False path
1171         return NULL;
1172 
1173     fp = PyFile_AsFile(f);
1174     if (fp == NULL) {
when treating unknown struct FILE * from bitarray/_bitarray.c:1173 as non-NULL
taking False path
1175         PyErr_SetString(PyExc_TypeError,
1176                         "first argument must be an open file");
1177         return NULL;
1178     }
1179 
1180     /* find number of bytes till EOF */
1181     if (nbytes < 0) {
when considering range: 0 <= value <= 0x7fffffffffffffff
taking False path
1182         if ((cur = ftell(fp)) < 0)
1183             goto EOFerror;
1184 
1185         if (fseek(fp, 0L, SEEK_END) || (nbytes = ftell(fp)) < 0)
1186             goto EOFerror;
1187 
1188         nbytes -= cur;
1189         if (fseek(fp, cur, SEEK_SET)) {
1190         EOFerror:
1191             PyErr_SetString(PyExc_EOFError, "could not find EOF");
1192             return NULL;
1193         }
1194     }
1195     if (nbytes == 0)
when considering range: 1 <= value <= 0x7fffffffffffffff
taking False path
1196         Py_RETURN_NONE;
1197 
1198     /* File exists and there are more than zero bytes to read */
1199     t = self->nbits;
1200     p = setunused(self);
1201     self->nbits += p;
1202 
1203     newsize = Py_SIZE(self) + nbytes;
1204     if (resize(self, BITS(newsize)) < 0)
when considering range: -0x80000000 <= value <= -1
taking True path
1205         return NULL;
1206 
1207     nread = fread(self->ob_item + (Py_SIZE(self) - nbytes), 1, nbytes, fp);
1208     if (nread < (size_t) nbytes) {
1209         newsize -= nbytes - nread;
1210         if (resize(self, BITS(newsize)) < 0)
1211             return NULL;
1212         PyErr_SetString(PyExc_EOFError, "not enough items in file");
1213         return NULL;
1214     }
1215 
1216     delete_n(self, t, p);
1217     Py_RETURN_NONE;
1218 }
returning (PyObject*)NULL without setting an exception
found 4 similar trace(s) to this