mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
[3.12] gh-105387: Limited C API implements Py_INCREF() as func (GH-105388) (#105763)
gh-105387: Limited C API implements Py_INCREF() as func (GH-105388)
In the limited C API version 3.12, Py_INCREF() and Py_DECREF()
functions are now implemented as opaque function calls to hide
implementation details.
(cherry picked from commit b542972dc1
)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
33d3069c45
commit
26bc2cc061
3 changed files with 18 additions and 8 deletions
|
@ -1693,6 +1693,11 @@ New Features
|
||||||
|
|
||||||
(Contributed by Eddie Elizondo in :gh:`84436`.)
|
(Contributed by Eddie Elizondo in :gh:`84436`.)
|
||||||
|
|
||||||
|
* In the limited C API version 3.12, :c:func:`Py_INCREF` and
|
||||||
|
:c:func:`Py_DECREF` functions are now implemented as opaque function calls to
|
||||||
|
hide implementation details.
|
||||||
|
(Contributed by Victor Stinner in :gh:`105387`.)
|
||||||
|
|
||||||
Porting to Python 3.12
|
Porting to Python 3.12
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -610,10 +610,11 @@ PyAPI_FUNC(void) _Py_DecRef(PyObject *);
|
||||||
|
|
||||||
static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
|
static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
|
||||||
{
|
{
|
||||||
#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API)
|
#if defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))
|
||||||
// Stable ABI for Python built in debug mode. _Py_IncRef() was added to
|
// Stable ABI implements Py_INCREF() as a function call on limited C API
|
||||||
// Python 3.10.0a7, use Py_IncRef() on older Python versions. Py_IncRef()
|
// version 3.12 and newer, and on Python built in debug mode. _Py_IncRef()
|
||||||
// accepts NULL whereas _Py_IncRef() doesn't.
|
// was added to Python 3.10.0a7, use Py_IncRef() on older Python versions.
|
||||||
|
// Py_IncRef() accepts NULL whereas _Py_IncRef() doesn't.
|
||||||
# if Py_LIMITED_API+0 >= 0x030a00A7
|
# if Py_LIMITED_API+0 >= 0x030a00A7
|
||||||
_Py_IncRef(op);
|
_Py_IncRef(op);
|
||||||
# else
|
# else
|
||||||
|
@ -647,10 +648,11 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
|
||||||
# define Py_INCREF(op) Py_INCREF(_PyObject_CAST(op))
|
# define Py_INCREF(op) Py_INCREF(_PyObject_CAST(op))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API)
|
#if defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))
|
||||||
// Stable ABI for Python built in debug mode. _Py_DecRef() was added to Python
|
// Stable ABI implements Py_DECREF() as a function call on limited C API
|
||||||
// 3.10.0a7, use Py_DecRef() on older Python versions. Py_DecRef() accepts NULL
|
// version 3.12 and newer, and on Python built in debug mode. _Py_DecRef() was
|
||||||
// whereas _Py_IncRef() doesn't.
|
// added to Python 3.10.0a7, use Py_DecRef() on older Python versions.
|
||||||
|
// Py_DecRef() accepts NULL whereas _Py_IncRef() doesn't.
|
||||||
static inline void Py_DECREF(PyObject *op) {
|
static inline void Py_DECREF(PyObject *op) {
|
||||||
# if Py_LIMITED_API+0 >= 0x030a00A7
|
# if Py_LIMITED_API+0 >= 0x030a00A7
|
||||||
_Py_DecRef(op);
|
_Py_DecRef(op);
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
In the limited C API version 3.12, :c:func:`Py_INCREF` and
|
||||||
|
:c:func:`Py_DECREF` functions are now implemented as opaque function calls
|
||||||
|
to hide implementation details. Patch by Victor Stinner.
|
Loading…
Add table
Add a link
Reference in a new issue