Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b3ac5c1

Browse files
committed
Py_NewRef() casts its argument to PyObject*
1 parent 6ebe8a5 commit b3ac5c1

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

pythoncapi_compat.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,24 @@ extern "C" {
2626

2727

2828
// bpo-42262 added Py_NewRef() to Python 3.10.0a3
29-
#if PY_VERSION_HEX < 0x030a00A3
30-
static inline PyObject* Py_NewRef(PyObject *obj)
29+
#if PY_VERSION_HEX < 0x030a00A3 && !defined(Py_NewRef)
30+
static inline PyObject* _Py_NewRef(PyObject *obj)
3131
{
3232
Py_INCREF(obj);
3333
return obj;
3434
}
35+
#define Py_NewRef(obj) _Py_NewRef(_PyObject_CAST(obj))
3536
#endif
3637

3738

3839
// bpo-42262 added Py_XNewRef() to Python 3.10.0a3
39-
#if PY_VERSION_HEX < 0x030a00A3
40-
static inline PyObject* Py_XNewRef(PyObject *obj)
40+
#if PY_VERSION_HEX < 0x030a00A3 && !defined(Py_XNewRef)
41+
static inline PyObject* _Py_XNewRef(PyObject *obj)
4142
{
4243
Py_XINCREF(obj);
4344
return obj;
4445
}
46+
#define Py_XNewRef(obj) _Py_XNewRef(_PyObject_CAST(obj))
4547
#endif
4648

4749

0 commit comments

Comments
 (0)