summaryrefslogtreecommitdiffstats
path: root/Objects/typeobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/typeobject.c')
-rw-r--r--Objects/typeobject.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 9f000d8..11f9c57 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -7144,8 +7144,11 @@ object___sizeof___impl(PyObject *self)
res = 0;
isize = Py_TYPE(self)->tp_itemsize;
- if (isize > 0)
- res = Py_SIZE(self) * isize;
+ if (isize > 0) {
+ /* This assumes that ob_size is valid if tp_itemsize is not 0,
+ which isn't true for PyLongObject. */
+ res = _PyVarObject_CAST(self)->ob_size * isize;
+ }
res += Py_TYPE(self)->tp_basicsize;
return PyLong_FromSsize_t(res);