summaryrefslogtreecommitdiffstats
path: root/Modules/_elementtree.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-30 16:22:52 (GMT)
committerGitHub <noreply@github.com>2022-11-30 16:22:52 (GMT)
commit85dd6cb6df996b1197266d1a50ecc9187a91e481 (patch)
tree774e93130f5e1b81dcd7a94982c189c718e84b91 /Modules/_elementtree.c
parent18a6967544795cdcce45b45700b7a9ed3994b8fb (diff)
downloadcpython-85dd6cb6df996b1197266d1a50ecc9187a91e481.zip
cpython-85dd6cb6df996b1197266d1a50ecc9187a91e481.tar.gz
cpython-85dd6cb6df996b1197266d1a50ecc9187a91e481.tar.bz2
gh-99845: Use size_t type in __sizeof__() methods (#99846)
The implementation of __sizeof__() methods using _PyObject_SIZE() now use an unsigned type (size_t) to compute the size, rather than a signed type (Py_ssize_t). Cast explicitly signed (Py_ssize_t) values to unsigned type (Py_ssize_t).
Diffstat (limited to 'Modules/_elementtree.c')
-rw-r--r--Modules/_elementtree.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 0c68ede..555c22f 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -876,19 +876,20 @@ deepcopy(PyObject *object, PyObject *memo)
/*[clinic input]
-_elementtree.Element.__sizeof__ -> Py_ssize_t
+_elementtree.Element.__sizeof__ -> size_t
[clinic start generated code]*/
-static Py_ssize_t
+static size_t
_elementtree_Element___sizeof___impl(ElementObject *self)
-/*[clinic end generated code: output=bf73867721008000 input=70f4b323d55a17c1]*/
+/*[clinic end generated code: output=baae4e7ae9fe04ec input=54e298c501f3e0d0]*/
{
- Py_ssize_t result = _PyObject_SIZE(Py_TYPE(self));
+ size_t result = _PyObject_SIZE(Py_TYPE(self));
if (self->extra) {
result += sizeof(ElementObjectExtra);
- if (self->extra->children != self->extra->_children)
- result += sizeof(PyObject*) * self->extra->allocated;
+ if (self->extra->children != self->extra->_children) {
+ result += (size_t)self->extra->allocated * sizeof(PyObject*);
+ }
}
return result;
}