File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,3 +97,13 @@ Type Objects
9797 types. This allows the caller to reference other heap types as base types.
9898
9999 .. versionadded :: 3.3
100+
101+ .. c :function :: void * PyType_GetSlot (PyTypeObject *type, int slot)
102+
103+ Return the function pointer stored int the given slot. If the
104+ result is *NULL *, this indicates that either the slot is *NULL *,
105+ or that the function was called with invalid parameters.
106+ Callers will typically cast the result pointer into the appropriate
107+ function type.
108+
109+ .. versionadded :: 3.4
Original file line number Diff line number Diff line change @@ -439,6 +439,9 @@ PyAPI_FUNC(PyObject*) PyType_FromSpec(PyType_Spec*);
439439#if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 >= 0x03030000
440440PyAPI_FUNC (PyObject * ) PyType_FromSpecWithBases (PyType_Spec * , PyObject * );
441441#endif
442+ #if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 >= 0x03040000
443+ PyAPI_FUNC (void * ) PyType_GetSlot (PyTypeObject * , int );
444+ #endif
442445
443446#ifndef Py_LIMITED_API
444447/* The *real* layout of a type object when allocated on the heap */
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ Release date: 2014-02-09
1010Core and Builtins
1111-----------------
1212
13+ - Issue #17162: Add PyType_GetSlot.
14+
1315- Issue #20162: Fix an alignment issue in the siphash24() hash function which
1416 caused a crash on PowerPC 64-bit (ppc64).
1517
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ static void
4444Xxo_dealloc (XxoObject * self )
4545{
4646 Py_XDECREF (self -> x_attr );
47- PyObject_Del (self );
47+ (( freefunc ) PyType_GetSlot ( Py_TYPE ( self ), Py_tp_free )) (self );
4848}
4949
5050static PyObject *
Original file line number Diff line number Diff line change @@ -2641,6 +2641,19 @@ PyType_FromSpec(PyType_Spec *spec)
26412641 return PyType_FromSpecWithBases (spec , NULL );
26422642}
26432643
2644+ void *
2645+ PyType_GetSlot (PyTypeObject * type , int slot )
2646+ {
2647+ if (!PyType_HasFeature (type , Py_TPFLAGS_HEAPTYPE )) {
2648+ PyErr_BadInternalCall ();
2649+ return NULL ;
2650+ }
2651+ if (slot >= Py_ARRAY_LENGTH (slotoffsets )) {
2652+ /* Extension module requesting slot from a future version */
2653+ return NULL ;
2654+ }
2655+ return * (void * * )(((char * )type ) + slotoffsets [slot ]);
2656+ }
26442657
26452658/* Internal API to look for a name through the MRO.
26462659 This returns a borrowed reference, and doesn't set an exception! */
Original file line number Diff line number Diff line change @@ -1539,7 +1539,7 @@ class db_found(Exception): pass
15391539
15401540 if 'd' not in sys .abiflags :
15411541 ext = Extension ('xxlimited' , ['xxlimited.c' ],
1542- define_macros = [('Py_LIMITED_API' , 1 )])
1542+ define_macros = [('Py_LIMITED_API' , '0x03040000' )])
15431543 self .extensions .append (ext )
15441544
15451545 return missing
You can’t perform that action at this time.
0 commit comments