Issue #23629: Fix the default __sizeof__ implementation for variable-sized objects.

This commit is contained in:
Antoine Pitrou 2015-03-10 22:32:00 +01:00
parent ebb8c2d528
commit a654510150
6 changed files with 22 additions and 29 deletions

View file

@ -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);