mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #23629: Fix the default __sizeof__ implementation for variable-sized objects.
This commit is contained in:
parent
ebb8c2d528
commit
a654510150
6 changed files with 22 additions and 29 deletions
|
@ -4258,7 +4258,7 @@ object_sizeof(PyObject *self, PyObject *args)
|
|||
res = 0;
|
||||
isize = self->ob_type->tp_itemsize;
|
||||
if (isize > 0)
|
||||
res = Py_SIZE(self->ob_type) * isize;
|
||||
res = Py_SIZE(self) * isize;
|
||||
res += self->ob_type->tp_basicsize;
|
||||
|
||||
return PyLong_FromSsize_t(res);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue