@@ -68,16 +68,6 @@ static inline PyObject* _Py_XNewRef(PyObject *obj)
6868#endif
6969
7070
71- // bpo-39573 added Py_SET_REFCNT() to Python 3.9.0a4
72- #if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_REFCNT)
73- static inline void _Py_SET_REFCNT (PyObject *ob, Py_ssize_t refcnt)
74- {
75- ob->ob_refcnt = refcnt;
76- }
77- #define Py_SET_REFCNT (ob, refcnt ) _Py_SET_REFCNT(_PyObject_CAST(ob), refcnt)
78- #endif
79-
80-
8171// Py_SETREF() and Py_XSETREF() were added to Python 3.5.2.
8272// It is excluded from the limited C API.
8373#if (PY_VERSION_HEX < 0x03050200 && !defined(Py_SETREF)) && !defined(Py_LIMITED_API)
@@ -114,37 +104,6 @@ static inline void _Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt)
114104# define Py_IsFalse (x ) Py_Is(x, Py_False)
115105#endif
116106
117-
118- // bpo-39573 added Py_SET_TYPE() to Python 3.9.0a4
119- #if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_TYPE)
120- static inline void _Py_SET_TYPE (PyObject *ob, PyTypeObject *type)
121- {
122- ob->ob_type = type;
123- }
124- #define Py_SET_TYPE (ob, type ) _Py_SET_TYPE(_PyObject_CAST(ob), type)
125- #endif
126-
127-
128- // bpo-39573 added Py_SET_SIZE() to Python 3.9.0a4
129- #if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_SIZE)
130- static inline void _Py_SET_SIZE (PyVarObject *ob, Py_ssize_t size)
131- {
132- ob->ob_size = size;
133- }
134- #define Py_SET_SIZE (ob, size ) _Py_SET_SIZE((PyVarObject*)(ob), size)
135- #endif
136-
137-
138- // bpo-40421 added PyFrame_GetCode() to Python 3.9.0b1
139- #if PY_VERSION_HEX < 0x030900B1 || defined(PYPY_VERSION)
140- static inline PyCodeObject* PyFrame_GetCode (PyFrameObject *frame)
141- {
142- assert (frame != _Py_NULL);
143- assert (frame->f_code != _Py_NULL);
144- return _Py_CAST (PyCodeObject*, Py_NewRef (frame->f_code ));
145- }
146- #endif
147-
148107static inline PyCodeObject* _PyFrame_GetCodeBorrow (PyFrameObject *frame)
149108{
150109 PyCodeObject *code = PyFrame_GetCode (frame);
@@ -153,15 +112,6 @@ static inline PyCodeObject* _PyFrame_GetCodeBorrow(PyFrameObject *frame)
153112}
154113
155114
156- // bpo-40421 added PyFrame_GetBack() to Python 3.9.0b1
157- #if PY_VERSION_HEX < 0x030900B1 && !defined(PYPY_VERSION)
158- static inline PyFrameObject* PyFrame_GetBack (PyFrameObject *frame)
159- {
160- assert (frame != _Py_NULL);
161- return _Py_CAST (PyFrameObject*, Py_XNewRef (frame->f_back ));
162- }
163- #endif
164-
165115#if !defined(PYPY_VERSION)
166116static inline PyFrameObject* _PyFrame_GetBackBorrow (PyFrameObject *frame)
167117{
@@ -279,26 +229,6 @@ PyFrame_GetVarString(PyFrameObject *frame, const char *name)
279229#endif
280230
281231
282- // bpo-39947 added PyThreadState_GetInterpreter() to Python 3.9.0a5
283- #if PY_VERSION_HEX < 0x030900A5 || defined(PYPY_VERSION)
284- static inline PyInterpreterState *
285- PyThreadState_GetInterpreter (PyThreadState *tstate)
286- {
287- assert (tstate != _Py_NULL);
288- return tstate->interp ;
289- }
290- #endif
291-
292-
293- // bpo-40429 added PyThreadState_GetFrame() to Python 3.9.0b1
294- #if PY_VERSION_HEX < 0x030900B1 && !defined(PYPY_VERSION)
295- static inline PyFrameObject* PyThreadState_GetFrame (PyThreadState *tstate)
296- {
297- assert (tstate != _Py_NULL);
298- return _Py_CAST (PyFrameObject *, Py_XNewRef (tstate->frame ));
299- }
300- #endif
301-
302232#if !defined(PYPY_VERSION)
303233static inline PyFrameObject*
304234_PyThreadState_GetFrameBorrow (PyThreadState *tstate)
@@ -310,35 +240,6 @@ _PyThreadState_GetFrameBorrow(PyThreadState *tstate)
310240#endif
311241
312242
313- // bpo-39947 added PyInterpreterState_Get() to Python 3.9.0a5
314- #if PY_VERSION_HEX < 0x030900A5 || defined(PYPY_VERSION)
315- static inline PyInterpreterState* PyInterpreterState_Get (void )
316- {
317- PyThreadState *tstate;
318- PyInterpreterState *interp;
319-
320- tstate = PyThreadState_GET ();
321- if (tstate == _Py_NULL) {
322- Py_FatalError (" GIL released (tstate is NULL)" );
323- }
324- interp = tstate->interp ;
325- if (interp == _Py_NULL) {
326- Py_FatalError (" no current interpreter" );
327- }
328- return interp;
329- }
330- #endif
331-
332-
333- // bpo-39947 added PyInterpreterState_Get() to Python 3.9.0a6
334- #if 0x030700A1 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x030900A6 && !defined(PYPY_VERSION)
335- static inline uint64_t PyThreadState_GetID (PyThreadState *tstate)
336- {
337- assert (tstate != _Py_NULL);
338- return tstate->id ;
339- }
340- #endif
341-
342243// bpo-43760 added PyThreadState_EnterTracing() to Python 3.11.0a2
343244#if PY_VERSION_HEX < 0x030B00A2 && !defined(PYPY_VERSION)
344245static inline void PyThreadState_EnterTracing (PyThreadState *tstate)
@@ -368,27 +269,6 @@ static inline void PyThreadState_LeaveTracing(PyThreadState *tstate)
368269#endif
369270
370271
371- // bpo-37194 added PyObject_CallNoArgs() to Python 3.9.0a1
372- // PyObject_CallNoArgs() added to PyPy 3.9.16-v7.3.11
373- #if !defined(PyObject_CallNoArgs) && PY_VERSION_HEX < 0x030900A1
374- static inline PyObject* PyObject_CallNoArgs (PyObject *func)
375- {
376- return PyObject_CallFunctionObjArgs (func, NULL );
377- }
378- #endif
379-
380-
381- // bpo-39245 made PyObject_CallOneArg() public (previously called
382- // _PyObject_CallOneArg) in Python 3.9.0a4
383- // PyObject_CallOneArg() added to PyPy 3.9.16-v7.3.11
384- #if !defined(PyObject_CallOneArg) && PY_VERSION_HEX < 0x030900A4
385- static inline PyObject* PyObject_CallOneArg (PyObject *func, PyObject *arg)
386- {
387- return PyObject_CallFunctionObjArgs (func, arg, NULL );
388- }
389- #endif
390-
391-
392272// bpo-1635741 added PyModule_AddObjectRef() to Python 3.10.0a3
393273#if PY_VERSION_HEX < 0x030A00A3
394274static inline int
@@ -414,58 +294,6 @@ PyModule_AddObjectRef(PyObject *module, const char *name, PyObject *value)
414294#endif
415295
416296
417- // bpo-40024 added PyModule_AddType() to Python 3.9.0a5
418- #if PY_VERSION_HEX < 0x030900A5
419- static inline int PyModule_AddType (PyObject *module , PyTypeObject *type)
420- {
421- const char *name, *dot;
422-
423- if (PyType_Ready (type) < 0 ) {
424- return -1 ;
425- }
426-
427- // inline _PyType_Name()
428- name = type->tp_name ;
429- assert (name != _Py_NULL);
430- dot = strrchr (name, ' .' );
431- if (dot != _Py_NULL) {
432- name = dot + 1 ;
433- }
434-
435- return PyModule_AddObjectRef (module , name, _PyObject_CAST (type));
436- }
437- #endif
438-
439-
440- // bpo-40241 added PyObject_GC_IsTracked() to Python 3.9.0a6.
441- // bpo-4688 added _PyObject_GC_IS_TRACKED() to Python 2.7.0a2.
442- #if PY_VERSION_HEX < 0x030900A6 && !defined(PYPY_VERSION)
443- static inline int PyObject_GC_IsTracked (PyObject* obj)
444- {
445- return (PyObject_IS_GC (obj) && _PyObject_GC_IS_TRACKED (obj));
446- }
447- #endif
448-
449- // bpo-40241 added PyObject_GC_IsFinalized() to Python 3.9.0a6.
450- // bpo-18112 added _PyGCHead_FINALIZED() to Python 3.4.0 final.
451- #if PY_VERSION_HEX < 0x030900A6 && PY_VERSION_HEX >= 0x030400F0 && !defined(PYPY_VERSION)
452- static inline int PyObject_GC_IsFinalized (PyObject *obj)
453- {
454- PyGC_Head *gc = _Py_CAST (PyGC_Head*, obj) - 1 ;
455- return (PyObject_IS_GC (obj) && _PyGCHead_FINALIZED (gc));
456- }
457- #endif
458-
459-
460- // bpo-39573 added Py_IS_TYPE() to Python 3.9.0a4
461- #if PY_VERSION_HEX < 0x030900A4 && !defined(Py_IS_TYPE)
462- static inline int _Py_IS_TYPE (PyObject *ob, PyTypeObject *type) {
463- return Py_TYPE (ob) == type;
464- }
465- #define Py_IS_TYPE (ob, type ) _Py_IS_TYPE(_PyObject_CAST(ob), type)
466- #endif
467-
468-
469297// bpo-46906 added PyFloat_Pack2() and PyFloat_Unpack2() to Python 3.11a7.
470298// bpo-11734 added _PyFloat_Pack2() and _PyFloat_Unpack2() to Python 3.6.0b1.
471299// Python 3.11a2 moved _PyFloat_Pack2() and _PyFloat_Unpack2() to the internal
@@ -592,81 +420,6 @@ static inline Py_ssize_t PyVectorcall_NARGS(size_t n)
592420#endif
593421
594422
595- // gh-105922 added PyObject_Vectorcall() to Python 3.9.0a4
596- #if PY_VERSION_HEX < 0x030900A4
597- static inline PyObject*
598- PyObject_Vectorcall (PyObject *callable, PyObject *const *args,
599- size_t nargsf, PyObject *kwnames)
600- {
601- #if PY_VERSION_HEX >= 0x030800B1 && !defined(PYPY_VERSION)
602- // bpo-36974 added _PyObject_Vectorcall() to Python 3.8.0b1
603- return _PyObject_Vectorcall (callable, args, nargsf, kwnames);
604- #else
605- PyObject *posargs = NULL , *kwargs = NULL ;
606- PyObject *res;
607- Py_ssize_t nposargs, nkwargs, i;
608-
609- if (nargsf != 0 && args == NULL ) {
610- PyErr_BadInternalCall ();
611- goto error;
612- }
613- if (kwnames != NULL && !PyTuple_Check (kwnames)) {
614- PyErr_BadInternalCall ();
615- goto error;
616- }
617-
618- nposargs = (Py_ssize_t)PyVectorcall_NARGS (nargsf);
619- if (kwnames) {
620- nkwargs = PyTuple_GET_SIZE (kwnames);
621- }
622- else {
623- nkwargs = 0 ;
624- }
625-
626- posargs = PyTuple_New (nposargs);
627- if (posargs == NULL ) {
628- goto error;
629- }
630- if (nposargs) {
631- for (i=0 ; i < nposargs; i++) {
632- PyTuple_SET_ITEM (posargs, i, Py_NewRef (*args));
633- args++;
634- }
635- }
636-
637- if (nkwargs) {
638- kwargs = PyDict_New ();
639- if (kwargs == NULL ) {
640- goto error;
641- }
642-
643- for (i = 0 ; i < nkwargs; i++) {
644- PyObject *key = PyTuple_GET_ITEM (kwnames, i);
645- PyObject *value = *args;
646- args++;
647- if (PyDict_SetItem (kwargs, key, value) < 0 ) {
648- goto error;
649- }
650- }
651- }
652- else {
653- kwargs = NULL ;
654- }
655-
656- res = PyObject_Call (callable, posargs, kwargs);
657- Py_DECREF (posargs);
658- Py_XDECREF (kwargs);
659- return res;
660-
661- error:
662- Py_DECREF (posargs);
663- Py_XDECREF (kwargs);
664- return NULL ;
665- #endif
666- }
667- #endif
668-
669-
670423// gh-106521 added PyObject_GetOptionalAttr() and
671424// PyObject_GetOptionalAttrString() to Python 3.13.0a1
672425#if PY_VERSION_HEX < 0x030D00A1
0 commit comments