Skip to content

Commit dcf7eea

Browse files
committed
Merge pull request #10 from dpryan79/missing_pyincref
Missing pyincref
2 parents 5f21266 + 9748ff8 commit dcf7eea

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pyBigWig.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ error :
8686

8787
//Accessor for the chroms, args is optional
8888
static PyObject *pyBwGetChroms(pyBigWigFile_t *self, PyObject *args) {
89-
PyObject *ret = Py_None, *val;
89+
PyObject *ret = NULL, *val;
9090
bigWigFile_t *bw = self->bw;
9191
char *chrom = NULL;
9292
uint32_t i;
@@ -107,6 +107,11 @@ static PyObject *pyBwGetChroms(pyBigWigFile_t *self, PyObject *args) {
107107
}
108108
}
109109

110+
if(!ret) {
111+
Py_INCREF(Py_None);
112+
ret = Py_None;
113+
}
114+
110115
return ret;
111116

112117
error :
@@ -173,7 +178,14 @@ static PyObject *pyBwGetStats(pyBigWigFile_t *self, PyObject *args, PyObject *kw
173178
}
174179

175180
ret = PyList_New(nBins);
176-
for(i=0; i<nBins; i++) PyList_SetItem(ret, i, (isnan(val[i]))?Py_None:PyFloat_FromDouble(val[i]));
181+
for(i=0; i<nBins; i++) {
182+
if(isnan(val[i])) {
183+
Py_INCREF(Py_None);
184+
PyList_SetItem(ret, i, Py_None);
185+
} else {
186+
PyList_SetItem(ret, i, PyFloat_FromDouble(val[i]));
187+
}
188+
}
177189
free(val);
178190

179191
return ret;

0 commit comments

Comments
 (0)