diff options
Diffstat (limited to 'Modules/_elementtree.c')
-rw-r--r-- | Modules/_elementtree.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index a43fe2e..ab3ef23 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -92,6 +92,9 @@ do { memory -= size; printf("%8d - %s\n", memory, comment); } while (0) #endif /* compatibility macros */ +#if (PY_VERSION_HEX < 0x02050000) +typedef int Py_ssize_t; +#endif #if (PY_VERSION_HEX < 0x02040000) #define PyDict_CheckExact PyDict_Check #if (PY_VERSION_HEX < 0x02020000) @@ -919,8 +922,9 @@ element_getiterator(ElementObject* self, PyObject* args) } static PyObject* -element_getitem(ElementObject* self, int index) +element_getitem(PyObject* _self, Py_ssize_t index) { + ElementObject* self = (ElementObject*)_self; if (!self->extra || index < 0 || index >= self->extra->length) { PyErr_SetString( PyExc_IndexError, @@ -934,9 +938,10 @@ element_getitem(ElementObject* self, int index) } static PyObject* -element_getslice(ElementObject* self, int start, int end) +element_getslice(PyObject* _self, Py_ssize_t start, Py_ssize_t end) { - int i; + ElementObject* self = (ElementObject*)_self; + Py_ssize_t i; PyObject* list; if (!self->extra) @@ -1022,7 +1027,7 @@ element_keys(ElementObject* self, PyObject* args) return PyDict_Keys(self->extra->attrib); } -static int +static Py_ssize_t element_length(ElementObject* self) { if (!self->extra) @@ -1161,8 +1166,9 @@ element_set(ElementObject* self, PyObject* args) } static int -element_setslice(ElementObject* self, int start, int end, PyObject* item) +element_setslice(PyObject* _self, Py_ssize_t start, Py_ssize_t end, PyObject* item) { + ElementObject* self = (ElementObject*)_self; int i, new, old; PyObject* recycle = NULL; @@ -1231,8 +1237,9 @@ element_setslice(ElementObject* self, int start, int end, PyObject* item) } static int -element_setitem(ElementObject* self, int index, PyObject* item) +element_setitem(PyObject* _self, Py_ssize_t index, PyObject* item) { + ElementObject* self = (ElementObject*)_self; int i; PyObject* old; @@ -1371,13 +1378,13 @@ element_setattr(ElementObject* self, const char* name, PyObject* value) } static PySequenceMethods element_as_sequence = { - (inquiry) element_length, + (lenfunc) element_length, 0, /* sq_concat */ 0, /* sq_repeat */ - (intargfunc) element_getitem, - (intintargfunc) element_getslice, - (intobjargproc) element_setitem, - (intintobjargproc) element_setslice, + element_getitem, + element_getslice, + element_setitem, + element_setslice, }; statichere PyTypeObject Element_Type = { |