summaryrefslogtreecommitdiff
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytearrayobject.c7
-rw-r--r--Objects/listobject.c7
-rw-r--r--Objects/setobject.c11
3 files changed, 11 insertions, 14 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 0ba6fb5b76..f24690a02b 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2151,10 +2151,9 @@ static PyObject *
bytearray_sizeof_impl(PyByteArrayObject *self)
/*[clinic end generated code: output=738abdd17951c427 input=e27320fd98a4bc5a]*/
{
- Py_ssize_t res;
-
- res = _PyObject_SIZE(Py_TYPE(self)) + self->ob_alloc * sizeof(char);
- return PyLong_FromSsize_t(res);
+ size_t res = _PyObject_SIZE(Py_TYPE(self));
+ res += (size_t)self->ob_alloc * sizeof(char);
+ return PyLong_FromSize_t(res);
}
static PySequenceMethods bytearray_as_sequence = {
diff --git a/Objects/listobject.c b/Objects/listobject.c
index da623c9719..0e696fbffb 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -2806,10 +2806,9 @@ static PyObject *
list___sizeof___impl(PyListObject *self)
/*[clinic end generated code: output=3417541f95f9a53e input=b8030a5d5ce8a187]*/
{
- Py_ssize_t res;
-
- res = _PyObject_SIZE(Py_TYPE(self)) + self->allocated * sizeof(void*);
- return PyLong_FromSsize_t(res);
+ size_t res = _PyObject_SIZE(Py_TYPE(self));
+ res += (size_t)self->allocated * sizeof(void*);
+ return PyLong_FromSize_t(res);
}
static PyObject *list_iter(PyObject *seq);
diff --git a/Objects/setobject.c b/Objects/setobject.c
index ae9e9b9944..fcdda2a0bc 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -1957,12 +1957,11 @@ done:
static PyObject *
set_sizeof(PySetObject *so, PyObject *Py_UNUSED(ignored))
{
- Py_ssize_t res;
-
- res = _PyObject_SIZE(Py_TYPE(so));
- if (so->table != so->smalltable)
- res = res + (so->mask + 1) * sizeof(setentry);
- return PyLong_FromSsize_t(res);
+ size_t res = _PyObject_SIZE(Py_TYPE(so));
+ if (so->table != so->smalltable) {
+ res += ((size_t)so->mask + 1) * sizeof(setentry);
+ }
+ return PyLong_FromSize_t(res);
}
PyDoc_STRVAR(sizeof_doc, "S.__sizeof__() -> size of S in memory, in bytes");