@@ -4253,12 +4253,12 @@ BIIterSeq_new(BlockIndexObject *bi, PyObject* selector, int8_t reversed) {
42534253 PyArrayObject * a = (PyArrayObject * )selector ;
42544254 if (PyArray_NDIM (a ) != 1 ) {
42554255 PyErr_SetString (PyExc_TypeError , "Arrays must be 1-dimensional" );
4256- return NULL ;
4256+ goto error ;
42574257 }
42584258 char kind = PyArray_DESCR (a )-> kind ;
42594259 if (kind != 'i' && kind != 'u' ) {
42604260 PyErr_SetString (PyExc_TypeError , "Arrays must integer kind" );
4261- return NULL ;
4261+ goto error ;
42624262 }
42634263 bii -> selector_len = PyArray_SIZE (a );
42644264 bii -> selector_is_array = 1 ;
@@ -4269,9 +4269,13 @@ BIIterSeq_new(BlockIndexObject *bi, PyObject* selector, int8_t reversed) {
42694269 }
42704270 else {
42714271 PyErr_SetString (PyExc_TypeError , "Input type not supported" );
4272- return NULL ;
4272+ goto error ;
42734273 }
42744274 return (PyObject * )bii ;
4275+ error :
4276+ Py_DECREF (bii -> bi );
4277+ Py_DECREF (bii -> selector );
4278+ return NULL ;
42754279}
42764280
42774281static void
@@ -4387,7 +4391,6 @@ typedef struct BIIterSliceObject {
43874391 Py_ssize_t count ; // count of , mutated in-place
43884392 // these are the normalized values truncated to the span of the bir_count; len is the realized length after extraction; step is always set to 1 if missing; len is 0 if no realized values
43894393 Py_ssize_t start ;
4390- Py_ssize_t stop ;
43914394 Py_ssize_t step ;
43924395 Py_ssize_t len ;
43934396} BIIterSliceObject ;
@@ -4405,14 +4408,14 @@ BIIterSlice_new(BlockIndexObject *bi, PyObject* slice, int8_t reversed) {
44054408 Py_INCREF (slice );
44064409 bii -> slice = slice ;
44074410
4408- bii -> reversed = reversed ;
44094411 bii -> count = 0 ;
4412+ Py_ssize_t stop ; // not needed
44104413
44114414 if (PySlice_Check (slice )) {
44124415 if (PySlice_GetIndicesEx (slice ,
44134416 bi -> bir_count ,
44144417 & bii -> start ,
4415- & bii -> stop ,
4418+ & stop ,
44164419 & bii -> step ,
44174420 & bii -> len )) {
44184421 goto error ;
@@ -4424,6 +4427,10 @@ BIIterSlice_new(BlockIndexObject *bi, PyObject* slice, int8_t reversed) {
44244427 PyErr_SetString (PyExc_TypeError , "Input type not supported" );
44254428 goto error ;
44264429 }
4430+ if ((bii -> reversed = reversed )) {
4431+ bii -> start += (bii -> step * (bii -> len - 1 ));
4432+ bii -> step *= -1 ;
4433+ }
44274434 return (PyObject * )bii ;
44284435error :
44294436 Py_DECREF (bii -> bi );
0 commit comments