@@ -314,21 +314,16 @@ PyAPI_FUNC(void) _Py_DecRefSharedDebug(PyObject *, const char *, int);
314314PyAPI_FUNC (void ) _Py_MergeZeroLocalRefcount (PyObject * );
315315#endif
316316
317- #if defined(Py_LIMITED_API ) && (Py_LIMITED_API + 0 >= 0x030c0000 || defined(Py_REF_DEBUG ))
318- // Stable ABI implements Py_DECREF() as a function call on limited C API
319- // version 3.12 and newer, and on Python built in debug mode. _Py_DecRef() was
320- // added to Python 3.10.0a7, use Py_DecRef() on older Python versions.
321- // Py_DecRef() accepts NULL whereas _Py_DecRef() doesn't.
322- static inline void Py_DECREF (PyObject * op ) {
323- # if Py_LIMITED_API + 0 >= 0x030a00A7
324- _Py_DecRef (op );
325- # else
326- Py_DecRef (op );
327- # endif
328- }
329- #define Py_DECREF (op ) Py_DECREF(_PyObject_CAST(op))
317+ PyAPI_FUNC (void ) Py_DecRefDebug (const char * filename , int lineno ,PyObject * );
318+
319+ #ifdef Py_DEBUG
320+ #define Py_DECREF (op ) Py_DecRefDebug(__FILE__, __LINE__, _PyObject_CAST(op))
321+ #else
322+ #define Py_DECREF (op ) Py_DecRef(_PyObject_CAST(op))
323+ #endif
330324
331- #elif defined(Py_GIL_DISABLED ) && defined(Py_REF_DEBUG )
325+ #ifdef Py_GIL_DISABLED
326+ # ifdef Py_REF_DEBUG
332327static inline void Py_DECREF (const char * filename , int lineno , PyObject * op )
333328{
334329 uint32_t local = _Py_atomic_load_uint32_relaxed (& op -> ob_ref_local );
@@ -353,8 +348,7 @@ static inline void Py_DECREF(const char *filename, int lineno, PyObject *op)
353348 }
354349}
355350#define Py_DECREF (op ) Py_DECREF(__FILE__, __LINE__, _PyObject_CAST(op))
356-
357- #elif defined(Py_GIL_DISABLED )
351+ # else
358352static inline void Py_DECREF (PyObject * op )
359353{
360354 uint32_t local = _Py_atomic_load_uint32_relaxed (& op -> ob_ref_local );
@@ -375,39 +369,9 @@ static inline void Py_DECREF(PyObject *op)
375369 }
376370}
377371#define Py_DECREF (op ) Py_DECREF(_PyObject_CAST(op))
378-
379- #elif defined(Py_REF_DEBUG )
380-
381- static inline void Py_DECREF (const char * filename , int lineno , PyObject * op )
382- {
383- #if SIZEOF_VOID_P > 4
384- /* If an object has been freed, it will have a negative full refcnt
385- * If it has not it been freed, will have a very large refcnt */
386- if (op -> ob_refcnt_full <= 0 || op -> ob_refcnt > (((PY_UINT32_T )- 1 ) - (1 <<20 ))) {
387- #else
388- if (op -> ob_refcnt <= 0 ) {
389- #endif
390- _Py_NegativeRefcount (filename , lineno , op );
391- }
392- if (_Py_IsImmortal (op )) {
393- _Py_DECREF_IMMORTAL_STAT_INC ();
394- return ;
395- }
396- _Py_DECREF_STAT_INC ();
397- _Py_DECREF_DecRefTotal ();
398- if (-- op -> ob_refcnt == 0 ) {
399- _Py_Dealloc (op );
400- }
401- }
402- #define Py_DECREF (op ) Py_DECREF(__FILE__, __LINE__, _PyObject_CAST(op))
403-
404- #else
405-
406- extern Py_NO_INLINE PyAPI_FUNC (void ) Py_DECREF (PyObject * op );
407- #define Py_DECREF (op ) Py_DECREF(_PyObject_CAST(op))
372+ # endif
408373#endif
409374
410-
411375/* Safely decref `op` and set `op` to NULL, especially useful in tp_clear
412376 * and tp_dealloc implementations.
413377 *
0 commit comments