summaryrefslogtreecommitdiffstats
path: root/Objects/boolobject.c
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2023-02-05 10:02:53 (GMT)
committerGitHub <noreply@github.com>2023-02-05 10:02:53 (GMT)
commit39017e04b55d4c110787551dc9a0cb753f27d700 (patch)
tree43c39ae5fa296b5bf195614330b0441d6c96db7a /Objects/boolobject.c
parent9b60ee976a6b66fe96c2d39051612999c26561e5 (diff)
downloadcpython-39017e04b55d4c110787551dc9a0cb753f27d700.zip
cpython-39017e04b55d4c110787551dc9a0cb753f27d700.tar.gz
cpython-39017e04b55d4c110787551dc9a0cb753f27d700.tar.bz2
gh-101266: Fix __sizeof__ for subclasses of int (#101394)
Fix the behaviour of the `__sizeof__` method (and hence the results returned by `sys.getsizeof`) for subclasses of `int`. Previously, `int` subclasses gave identical results to the `int` base class, ignoring the presence of the instance dictionary. <!-- gh-issue-number: gh-101266 --> * Issue: gh-101266 <!-- /gh-issue-number -->
Diffstat (limited to 'Objects/boolobject.c')
-rw-r--r--Objects/boolobject.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/boolobject.c b/Objects/boolobject.c
index 55b4a40..a035f46 100644
--- a/Objects/boolobject.c
+++ b/Objects/boolobject.c
@@ -4,6 +4,8 @@
#include "pycore_object.h" // _Py_FatalRefcountError()
#include "pycore_runtime.h" // _Py_ID()
+#include <stddef.h>
+
/* We define bool_repr to return "False" or "True" */
static PyObject *
@@ -153,8 +155,8 @@ bool_dealloc(PyObject* Py_UNUSED(ignore))
PyTypeObject PyBool_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"bool",
- sizeof(struct _longobject),
- 0,
+ offsetof(struct _longobject, long_value.ob_digit), /* tp_basicsize */
+ sizeof(digit), /* tp_itemsize */
bool_dealloc, /* tp_dealloc */
0, /* tp_vectorcall_offset */
0, /* tp_getattr */