summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-05-23 15:58:34 (GMT)
committerGitHub <noreply@github.com>2024-05-23 15:58:34 (GMT)
commit251ef2e36f61a1c4b7c628ba9dc38a10a355a058 (patch)
tree18d6c2bc1c11eb969fc3216b549feb2d67f78b1a /Objects
parentdbe4f8a2e8b9751bbe8d0551e55d27267b0bfcde (diff)
downloadcpython-251ef2e36f61a1c4b7c628ba9dc38a10a355a058.zip
cpython-251ef2e36f61a1c4b7c628ba9dc38a10a355a058.tar.gz
cpython-251ef2e36f61a1c4b7c628ba9dc38a10a355a058.tar.bz2
[3.13] GH-117195: Avoid assertion error in `object.__sizeof__` (GH-117220) (GH-119456)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index b7c3fcf..4af4971 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -7037,8 +7037,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);