[Python-checkins] bpo-39542: Move object.h debug functions to internal C API (GH-18331)

Victor Stinner webhook-mailer at python.org
Mon Feb 3 11:28:39 EST 2020


https://github.com/python/cpython/commit/4b524161a0f9d50d782e739a3708434ffd4e94a5
commit: 4b524161a0f9d50d782e739a3708434ffd4e94a5
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-02-03T17:28:26+01:00
summary:

bpo-39542: Move object.h debug functions to internal C API (GH-18331)

Move the following functions from the public C API to the internal C
API:

* _PyDebug_PrintTotalRefs(),
* _Py_PrintReferenceAddresses()
* _Py_PrintReferences()

files:
M Include/internal/pycore_object.h
M Include/object.h
M Python/pylifecycle.c
M Python/pythonrun.c

diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h
index ba6636d7f8cfc..eac39c8a3fccc 100644
--- a/Include/internal/pycore_object.h
+++ b/Include/internal/pycore_object.h
@@ -77,6 +77,15 @@ static inline void _PyObject_GC_UNTRACK_impl(const char *filename, int lineno,
 #define _PyObject_GC_UNTRACK(op) \
     _PyObject_GC_UNTRACK_impl(__FILE__, __LINE__, _PyObject_CAST(op))
 
+#ifdef Py_REF_DEBUG
+extern void _PyDebug_PrintTotalRefs(void);
+#endif
+
+#ifdef Py_TRACE_REFS
+extern void _Py_PrintReferences(FILE *);
+extern void _Py_PrintReferenceAddresses(FILE *);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/Include/object.h b/Include/object.h
index 1a2e704e93d23..e1cc47aeb3d5c 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -395,11 +395,6 @@ PyAPI_FUNC(void) _Py_NegativeRefcount(const char *filename, int lineno,
 PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void);
 #define _Py_INC_REFTOTAL        _Py_RefTotal++
 #define _Py_DEC_REFTOTAL        _Py_RefTotal--
-
-/* Py_REF_DEBUG also controls the display of refcounts and memory block
- * allocations at the interactive prompt and at interpreter shutdown
- */
-PyAPI_FUNC(void) _PyDebug_PrintTotalRefs(void);
 #else
 #define _Py_INC_REFTOTAL
 #define _Py_DEC_REFTOTAL
@@ -413,8 +408,6 @@ PyAPI_FUNC(int) _PyTraceMalloc_NewReference(PyObject *op);
 /* Py_TRACE_REFS is such major surgery that we call external routines. */
 PyAPI_FUNC(void) _Py_NewReference(PyObject *);
 PyAPI_FUNC(void) _Py_ForgetReference(PyObject *);
-PyAPI_FUNC(void) _Py_PrintReferences(FILE *);
-PyAPI_FUNC(void) _Py_PrintReferenceAddresses(FILE *);
 PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
 #else
 /* Without Py_TRACE_REFS, there's little enough to do that we expand code
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index f1307356a7da0..fbeebbdf99da5 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -10,6 +10,7 @@
 #include "pycore_initconfig.h"
 #include "pycore_fileutils.h"
 #include "pycore_hamt.h"
+#include "pycore_object.h"
 #include "pycore_pathconfig.h"
 #include "pycore_pyerrors.h"
 #include "pycore_pylifecycle.h"
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index b68a0b5572a1b..f4ded2e24a37e 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -12,6 +12,7 @@
 
 #include "Python-ast.h"
 #undef Yield   /* undefine macro conflicting with <winbase.h> */
+#include "pycore_object.h"
 #include "pycore_pyerrors.h"
 #include "pycore_pylifecycle.h"
 #include "pycore_pystate.h"



More information about the Python-checkins mailing list