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

This commit is contained in:
Antoine Pitrou 2015-03-10 22:35:24 +01:00
commit 63afdaa110
6 changed files with 22 additions and 52 deletions

View file

@ -4276,7 +4276,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);