Issue #28959: Added private macro PyDict_GET_SIZE for retrieving the size of dict.
diff --git a/Include/dictobject.h b/Include/dictobject.h
index 30f114e..885694b 100644
--- a/Include/dictobject.h
+++ b/Include/dictobject.h
@@ -106,6 +106,8 @@
 PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp);
 PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key);
 #ifndef Py_LIMITED_API
+/* Get the number of items of a dictionary. */
+#define PyDict_GET_SIZE(mp)  (assert(PyDict_Check(mp)),((PyDictObject *)mp)->ma_used)
 PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, Py_hash_t hash);
 PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
 PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
diff --git a/Include/odictobject.h b/Include/odictobject.h
index c1d9592..9410a0d 100644
--- a/Include/odictobject.h
+++ b/Include/odictobject.h
@@ -21,7 +21,7 @@
 
 #define PyODict_Check(op) PyObject_TypeCheck(op, &PyODict_Type)
 #define PyODict_CheckExact(op) (Py_TYPE(op) == &PyODict_Type)
-#define PyODict_SIZE(op) ((PyDictObject *)op)->ma_used
+#define PyODict_SIZE(op) PyDict_GET_SIZE((op))
 #define PyODict_HasKey(od, key) (PyMapping_HasKey(PyObject *)od, key)
 
 PyAPI_FUNC(PyObject *) PyODict_New(void);