Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size.
This allows sys.getsize() to work correctly with their subclasses with
__slots__ defined.
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 5647b57..c59ad24 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2974,7 +2974,7 @@
 {
     Py_ssize_t res;
 
-    res = sizeof(PyByteArrayObject) + self->ob_alloc * sizeof(char);
+    res = _PyObject_SIZE(Py_TYPE(self)) + self->ob_alloc * sizeof(char);
     return PyLong_FromSsize_t(res);
 }
 
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index 353f414..b0e3446 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -384,7 +384,7 @@
 {
     Py_ssize_t res;
 
-    res = sizeof(PyCodeObject);
+    res = _PyObject_SIZE(Py_TYPE(co));
     if (co->co_cell2arg != NULL && co->co_cellvars != NULL)
         res += PyTuple_GET_SIZE(co->co_cellvars) * sizeof(unsigned char);
     return PyLong_FromSsize_t(res);
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 624ae9b..3e6e112 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -2560,7 +2560,7 @@
     Py_ssize_t size, res;
 
     size = DK_SIZE(mp->ma_keys);
-    res = sizeof(PyDictObject);
+    res = _PyObject_SIZE(Py_TYPE(mp));
     if (mp->ma_values)
         res += size * sizeof(PyObject*);
     /* If the dictionary is split, the keys portion is accounted-for
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 45e54ce..eee7c68 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -2324,7 +2324,7 @@
 {
     Py_ssize_t res;
 
-    res = sizeof(PyListObject) + self->allocated * sizeof(void*);
+    res = _PyObject_SIZE(Py_TYPE(self)) + self->allocated * sizeof(void*);
     return PyLong_FromSsize_t(res);
 }
 
diff --git a/Objects/odictobject.c b/Objects/odictobject.c
index 5ad88bc..4e51f4d 100644
--- a/Objects/odictobject.c
+++ b/Objects/odictobject.c
@@ -951,8 +951,6 @@
     if (res == -1 && PyErr_Occurred())
         return NULL;
 
-    res += sizeof(PyODictObject) - sizeof(PyDictObject);
-
     /* instance dict */
     pylong = _PyDict_SizeOf((PyDictObject *)od->od_inst_dict);
     if (pylong == NULL)
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 704d7e2..2faaf12 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -1940,7 +1940,7 @@
 {
     Py_ssize_t res;
 
-    res = sizeof(PySetObject);
+    res = _PyObject_SIZE(Py_TYPE(so));
     if (so->table != so->smalltable)
         res = res + (so->mask + 1) * sizeof(setentry);
     return PyLong_FromSsize_t(res);