summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2014-02-04 08:33:05 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2014-02-04 08:33:05 (GMT)
commitca7b04644ce7cbc828a28f47be421029acb38eb7 (patch)
tree0a5218b57db2d7b322b1dec957872319f3bed533 /Objects
parent83bdfa08f7747466d0925323a7d94a26470fcd32 (diff)
downloadcpython-ca7b04644ce7cbc828a28f47be421029acb38eb7.zip
cpython-ca7b04644ce7cbc828a28f47be421029acb38eb7.tar.gz
cpython-ca7b04644ce7cbc828a28f47be421029acb38eb7.tar.bz2
Issue #17162: Add PyType_GetSlot.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index cbbb58a..349a6fd 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2641,6 +2641,19 @@ PyType_FromSpec(PyType_Spec *spec)
return PyType_FromSpecWithBases(spec, NULL);
}
+void *
+PyType_GetSlot(PyTypeObject *type, int slot)
+{
+ if (!PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE)) {
+ PyErr_BadInternalCall();
+ return NULL;
+ }
+ if (slot >= Py_ARRAY_LENGTH(slotoffsets)) {
+ /* Extension module requesting slot from a future version */
+ return NULL;
+ }
+ return *(void**)(((char*)type) + slotoffsets[slot]);
+}
/* Internal API to look for a name through the MRO.
This returns a borrowed reference, and doesn't set an exception! */