mirror of
https://github.com/python/cpython.git
synced 2026-04-05 03:21:05 +00:00
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).
This commit is contained in:
parent
18a6967544
commit
85dd6cb6df
15 changed files with 85 additions and 108 deletions
|
|
@ -1773,9 +1773,9 @@ static PyObject *
|
|||
array_array___sizeof___impl(arrayobject *self)
|
||||
/*[clinic end generated code: output=d8e1c61ebbe3eaed input=805586565bf2b3c6]*/
|
||||
{
|
||||
Py_ssize_t res;
|
||||
res = _PyObject_SIZE(Py_TYPE(self)) + self->allocated * self->ob_descr->itemsize;
|
||||
return PyLong_FromSsize_t(res);
|
||||
size_t res = _PyObject_SIZE(Py_TYPE(self));
|
||||
res += (size_t)self->allocated * (size_t)self->ob_descr->itemsize;
|
||||
return PyLong_FromSize_t(res);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue