diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2014-02-04 08:33:05 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2014-02-04 08:33:05 (GMT) |
commit | ca7b04644ce7cbc828a28f47be421029acb38eb7 (patch) | |
tree | 0a5218b57db2d7b322b1dec957872319f3bed533 /Objects | |
parent | 83bdfa08f7747466d0925323a7d94a26470fcd32 (diff) | |
download | cpython-ca7b04644ce7cbc828a28f47be421029acb38eb7.zip cpython-ca7b04644ce7cbc828a28f47be421029acb38eb7.tar.gz cpython-ca7b04644ce7cbc828a28f47be421029acb38eb7.tar.bz2 |
Issue #17162: Add PyType_GetSlot.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 13 |
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! */ |