# define PyObject_GetItem py3_PyObject_GetItem
# define PyObject_IsTrue py3_PyObject_IsTrue
# define PyModule_GetDict py3_PyModule_GetDict
-# if defined(USE_LIMITED_API) \
- && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))
-# undef Py_INCREF
-# if Py_LIMITED_API+0 >= 0x030a00A7
-# define _Py_IncRef py3__Py_IncRef
-# define Py_INCREF _Py_IncRef
-# else
-# define Py_IncRef py3_Py_IncRef
-# define Py_INCREF Py_IncRef
-# endif
+# ifdef USE_LIMITED_API
+# define Py_IncRef py3_Py_IncRef
+# define Py_DecRef py3_Py_DecRef
# endif
# ifdef USE_LIMITED_API
# define Py_CompileString py3_Py_CompileString
static void (*py3_PyErr_SetString)(PyObject *, const char *);
static void (*py3_PyErr_SetObject)(PyObject *, PyObject *);
static int (*py3_PyErr_ExceptionMatches)(PyObject *);
-# if defined(USE_LIMITED_API) \
- && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))
-# if Py_LIMITED_API+0 >= 0x030a00A7
-# define _Py_IncRef py3__Py_IncRef
-static void (*py3__Py_IncRef)(PyObject *);
-# else
+# ifdef USE_LIMITED_API
static void (*py3_Py_IncRef)(PyObject *);
-# endif
+static void (*py3_Py_DecRef)(PyObject *);
# endif
# ifdef USE_LIMITED_API
static PyObject* (*py3_Py_CompileString)(const char *, const char *, int);
{"PyErr_SetString", (PYTHON_PROC*)&py3_PyErr_SetString},
{"PyErr_SetObject", (PYTHON_PROC*)&py3_PyErr_SetObject},
{"PyErr_ExceptionMatches", (PYTHON_PROC*)&py3_PyErr_ExceptionMatches},
-# if defined(USE_LIMITED_API) \
- && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))
-# if Py_LIMITED_API+0 >= 0x030a00A7
- {"_Py_IncRef", (PYTHON_PROC*)&py3__Py_IncRef},
-# else
+# ifdef USE_LIMITED_API
{"Py_IncRef", (PYTHON_PROC*)&py3_Py_IncRef},
-# endif
+ {"Py_DecRef", (PYTHON_PROC*)&py3_Py_DecRef},
# endif
# ifdef USE_LIMITED_API
{"Py_CompileString", (PYTHON_PROC*)&py3_Py_CompileString},
# define Py_XDECREF(op) py3__Py_XDECREF(_PyObject_CAST(op))
# endif
-# if defined(USE_LIMITED_API) \
- && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))
- static inline void
-py3__Py_XINCREF(PyObject *op)
-{
- if (op != NULL)
- {
- Py_INCREF(op);
- }
-}
+# ifdef USE_LIMITED_API
+// Use stable versions of inc/dec ref. Note that these always null-check and
+// therefore there's no difference between XINCREF and INCREF.
+# undef Py_INCREF
+# define Py_INCREF(obj) Py_IncRef((PyObject *)obj)
# undef Py_XINCREF
-# define Py_XINCREF(op) py3__Py_XINCREF(_PyObject_CAST(op))
+# define Py_XINCREF(obj) Py_IncRef((PyObject *)obj)
+
+# undef Py_DECREF
+# define Py_DECREF(obj) Py_DecRef((PyObject *)obj)
+# undef Py_XDECREF
+# define Py_XDECREF(obj) Py_DecRef((PyObject *)obj)
# endif
# if PY_VERSION_HEX >= 0x030900b0