From 311653dab59a8ae54de96b6e07546ab53b151c34 Mon Sep 17 00:00:00 2001 From: Tobias Gustafsson Date: Wed, 12 Jan 2022 21:20:34 +0100 Subject: [PATCH] Fix #236 compilation errors under Python 3.10 due to signedness issues --- pvectorcmodule.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pvectorcmodule.c b/pvectorcmodule.c index a7b1bd4..de3e17c 100644 --- a/pvectorcmodule.c +++ b/pvectorcmodule.c @@ -142,12 +142,12 @@ static Py_ssize_t PVector_len(PVector *self) { } /* Convenience macros */ -#define ROOT_NODE_FULL(vec) ((vec->count >> SHIFT) > (1 << vec->shift)) +#define ROOT_NODE_FULL(vec) ((vec->count >> SHIFT) > (Py_ssize_t)(1 << vec->shift)) #define TAIL_OFF(vec) ((vec->count < BRANCH_FACTOR) ? 0 : (((vec->count - 1) >> SHIFT) << SHIFT)) #define TAIL_SIZE(vec) (vec->count - TAIL_OFF(vec)) #define PVector_CheckExact(op) (Py_TYPE(op) == &PVectorType) -static VNode* nodeFor(PVector *self, int i){ +static VNode* nodeFor(PVector *self, Py_ssize_t i){ int level; if((i >= 0) && (i < self->count)) { if(i >= TAIL_OFF(self)) { @@ -414,7 +414,7 @@ static PyObject* PVector_repeat(PVector *self, Py_ssize_t n) { } else if ((self->count * n)/self->count != n) { return PyErr_NoMemory(); } else { - int i, j; + Py_ssize_t i, j; PVector *newVec = copyPVector(self); for(i=0; i<(n-1); i++) { for(j=0; jcount; j++) { @@ -1203,10 +1203,10 @@ static PyMethodDef PVectorEvolver_methods[] = { {"append", (PyCFunction)PVectorEvolver_append, METH_O, "Appends an element"}, {"extend", (PyCFunction)PVectorEvolver_extend, METH_O|METH_COEXIST, "Extend"}, {"set", (PyCFunction)PVectorEvolver_set, METH_VARARGS, "Set item"}, - {"delete", (PyCFunction)PVectorEvolver_delete, METH_VARARGS, "Delete item"}, - {"persistent", (PyCFunction)PVectorEvolver_persistent, METH_NOARGS, "Create PVector from evolver"}, - {"is_dirty", (PyCFunction)PVectorEvolver_is_dirty, METH_NOARGS, "Check if evolver contains modifications"}, - {NULL, NULL} /* sentinel */ + {"delete", (PyCFunction)PVectorEvolver_delete, METH_VARARGS, "Delete item"}, + {"persistent", (PyCFunction)PVectorEvolver_persistent, METH_NOARGS, "Create PVector from evolver"}, + {"is_dirty", (PyCFunction)PVectorEvolver_is_dirty, METH_NOARGS, "Check if evolver contains modifications"}, + {NULL, NULL} /* sentinel */ }; static PyTypeObject PVectorEvolverType = {