[Python-checkins] [3.12] gh-102304: Rename _Py_IncRefTotal_DO_NOT_USE_THIS() (GH-107193) (#107199)

vstinner webhook-mailer at python.org
Mon Jul 24 16:59:55 EDT 2023


https://github.com/python/cpython/commit/3923639a77656915c3499b0283a45da727308f2a
commit: 3923639a77656915c3499b0283a45da727308f2a
branch: 3.12
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: vstinner <vstinner at python.org>
date: 2023-07-24T22:59:51+02:00
summary:

[3.12] gh-102304: Rename _Py_IncRefTotal_DO_NOT_USE_THIS() (GH-107193) (#107199)

gh-102304: Rename _Py_IncRefTotal_DO_NOT_USE_THIS() (GH-107193)

* Rename _Py_IncRefTotal_DO_NOT_USE_THIS() to _Py_INCREF_IncRefTotal()
* Rename _Py_DecRefTotal_DO_NOT_USE_THIS() to _Py_DECREF_DecRefTotal()
* Remove temporary _Py_INC_REFTOTAL() and _Py_DEC_REFTOTAL() macros
(cherry picked from commit 8ebc9fc321ba1eeb3282c2170f351c54956893e6)

Co-authored-by: Victor Stinner <vstinner at python.org>

files:
M Include/object.h
M Objects/object.c

diff --git a/Include/object.h b/Include/object.h
index 3ef64511399c6..7564b9623be79 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -588,10 +588,8 @@ you can count such references to the type object.)
 #if defined(Py_REF_DEBUG) && !defined(Py_LIMITED_API)
 PyAPI_FUNC(void) _Py_NegativeRefcount(const char *filename, int lineno,
                                       PyObject *op);
-PyAPI_FUNC(void) _Py_IncRefTotal_DO_NOT_USE_THIS(void);
-PyAPI_FUNC(void) _Py_DecRefTotal_DO_NOT_USE_THIS(void);
-#    define _Py_INC_REFTOTAL() _Py_IncRefTotal_DO_NOT_USE_THIS()
-#    define _Py_DEC_REFTOTAL() _Py_DecRefTotal_DO_NOT_USE_THIS()
+PyAPI_FUNC(void) _Py_INCREF_IncRefTotal(void);
+PyAPI_FUNC(void) _Py_DECREF_DecRefTotal(void);
 #endif  // Py_REF_DEBUG && !Py_LIMITED_API
 
 PyAPI_FUNC(void) _Py_Dealloc(PyObject *);
@@ -640,7 +638,7 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
 #endif
     _Py_INCREF_STAT_INC();
 #ifdef Py_REF_DEBUG
-    _Py_INC_REFTOTAL();
+    _Py_INCREF_IncRefTotal();
 #endif
 #endif
 }
@@ -669,7 +667,7 @@ static inline void Py_DECREF(const char *filename, int lineno, PyObject *op)
         return;
     }
     _Py_DECREF_STAT_INC();
-    _Py_DEC_REFTOTAL();
+    _Py_DECREF_DecRefTotal();
     if (--op->ob_refcnt != 0) {
         if (op->ob_refcnt < 0) {
             _Py_NegativeRefcount(filename, lineno, op);
@@ -697,9 +695,6 @@ static inline Py_ALWAYS_INLINE void Py_DECREF(PyObject *op)
 #define Py_DECREF(op) Py_DECREF(_PyObject_CAST(op))
 #endif
 
-#undef _Py_INC_REFTOTAL
-#undef _Py_DEC_REFTOTAL
-
 
 /* Safely decref `op` and set `op` to NULL, especially useful in tp_clear
  * and tp_dealloc implementations.
diff --git a/Objects/object.c b/Objects/object.c
index b8bdf459201d9..6a73c3588da79 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -206,14 +206,14 @@ _Py_NegativeRefcount(const char *filename, int lineno, PyObject *op)
 
 /* This is used strictly by Py_INCREF(). */
 void
-_Py_IncRefTotal_DO_NOT_USE_THIS(void)
+_Py_INCREF_IncRefTotal(void)
 {
     reftotal_increment(_PyInterpreterState_GET());
 }
 
 /* This is used strictly by Py_DECREF(). */
 void
-_Py_DecRefTotal_DO_NOT_USE_THIS(void)
+_Py_DECREF_DecRefTotal(void)
 {
     reftotal_decrement(_PyInterpreterState_GET());
 }



More information about the Python-checkins mailing list