gh-111506: Rename _Py_SetRefcnt() to Py_SET_REFCNT() by vstinner · Pull Request #112794 · python/cpython · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Doc/data/stable_abi.dat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions Include/object.h
2 changes: 1 addition & 1 deletion Lib/test/test_stable_abi_ctypes.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ OBJECT_OBJS= \
Objects/moduleobject.o \
Objects/namespaceobject.o \
Objects/object.o \
Objects/object_abi.o \
Objects/obmalloc.o \
Objects/picklebufobject.o \
Objects/rangeobject.o \
Expand Down
3 changes: 1 addition & 2 deletions Misc/stable_abi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2478,6 +2478,5 @@
added = '3.13'
[function.PySys_AuditTuple]
added = '3.13'
[function._Py_SetRefcnt]
[function.Py_SET_REFCNT]
added = '3.13'
abi_only = true
52 changes: 0 additions & 52 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -2886,55 +2886,3 @@ PyObject_GET_WEAKREFS_LISTPTR(PyObject *op)
{
return _PyObject_GET_WEAKREFS_LISTPTR(op);
}


#undef Py_NewRef
#undef Py_XNewRef

// Export Py_NewRef() and Py_XNewRef() as regular functions for the stable ABI.
PyObject*
Py_NewRef(PyObject *obj)
{
return _Py_NewRef(obj);
}

PyObject*
Py_XNewRef(PyObject *obj)
{
return _Py_XNewRef(obj);
}

#undef Py_Is
#undef Py_IsNone
#undef Py_IsTrue
#undef Py_IsFalse

// Export Py_Is(), Py_IsNone(), Py_IsTrue(), Py_IsFalse() as regular functions
// for the stable ABI.
int Py_Is(PyObject *x, PyObject *y)
{
return (x == y);
}

int Py_IsNone(PyObject *x)
{
return Py_Is(x, Py_None);
}

int Py_IsTrue(PyObject *x)
{
return Py_Is(x, Py_True);
}

int Py_IsFalse(PyObject *x)
{
return Py_Is(x, Py_False);
}


// Py_SET_REFCNT() implementation for stable ABI
void
_Py_SetRefcnt(PyObject *ob, Py_ssize_t refcnt)
{
Py_SET_REFCNT(ob, refcnt);
}
61 changes: 61 additions & 0 deletions Objects/object_abi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Stable ABI implementation for PyObject functions.


// Rename static inline functions with macros
#define _Py_STABLE_ABI_IMPL

#include "Python.h"


#undef Py_NewRef
#undef Py_XNewRef

// Export Py_NewRef() and Py_XNewRef() as regular functions for the stable ABI.
PyObject*
Py_NewRef(PyObject *obj)
{
return _Py_NewRef(obj);
}

PyObject*
Py_XNewRef(PyObject *obj)
{
return _Py_XNewRef(obj);
}


#undef Py_Is
#undef Py_IsNone
#undef Py_IsTrue
#undef Py_IsFalse

// Export Py_Is(), Py_IsNone(), Py_IsTrue(), Py_IsFalse() as regular functions
// for the stable ABI.
int Py_Is(PyObject *x, PyObject *y)
{
return (x == y);
}

int Py_IsNone(PyObject *x)
{
return Py_Is(x, Py_None);
}

int Py_IsTrue(PyObject *x)
{
return Py_Is(x, Py_True);
}

int Py_IsFalse(PyObject *x)
{
return Py_Is(x, Py_False);
}


#undef Py_SET_REFCNT

PyAPI_FUNC(void)
Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt)
{
_Py_SET_REFCNT(ob, refcnt);
}
2 changes: 1 addition & 1 deletion PC/python3dll.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@
<ClCompile Include="..\Objects\moduleobject.c" />
<ClCompile Include="..\Objects\namespaceobject.c" />
<ClCompile Include="..\Objects\object.c" />
<ClCompile Include="..\Objects\object_abi.c" />
<ClCompile Include="..\Objects\obmalloc.c" />
<ClCompile Include="..\Objects\odictobject.c" />
<ClCompile Include="..\Objects\picklebufobject.c" />
Expand Down
3 changes: 3 additions & 0 deletions PCbuild/pythoncore.vcxproj.filters