8000 bpo-39542: Move object.h debug functions to internal C API (GH-18331) · python/cpython@4b52416 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b52416

Browse files
authored
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()
1 parent c6e5c11 commit 4b52416

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

Include/internal/pycore_object.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ static inline void _PyObject_GC_UNTRACK_impl(const char *filename, int lineno,
7777
#define _PyObject_GC_UNTRACK(op) \
7878
_PyObject_GC_UNTRACK_impl(__FILE__, __LINE__, _PyObject_CAST(op))
7979

80+
#ifdef Py_REF_DEBUG
81+
extern void _PyDebug_PrintTotalRefs(void);
82+
#endif
83+
84+
#ifdef Py_TRACE_REFS
85+
extern void _Py_PrintReferences(FILE *);
86+
extern void _Py_PrintReferenceAddresses(FILE *);
87+
#endif
88+
8089
#ifdef __cplusplus
8190
}
8291
#endif

Include/object.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,6 @@ PyAPI_FUNC(void) _Py_NegativeRefcount(const char *filename, int lineno,
395395
PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void);
396396
#define _Py_INC_REFTOTAL _Py_RefTotal++
397397
#define _Py_DEC_REFTOTAL _Py_RefTotal--
398-
399-
/* Py_REF_DEBUG also controls the display of refcounts and memory block
400-
* allocations at the interactive prompt and at interpreter shutdown
401-
*/
402-
PyAPI_FUNC(void) _PyDebug_PrintTotalRefs(void);
403398
#else
404399
#define _Py_INC_REFTOTAL
405400
#define _Py_DEC_REFTOTAL
@@ -413,8 +408,6 @@ PyAPI_FUNC(int) _PyTraceMalloc_NewReference(PyObject *op);
413408
/* Py_TRACE_REFS is such major surgery that we call external routines. */
414409
PyAPI_FUNC(void) _Py_NewReference(PyObject *);
415410
PyAPI_FUNC(void) _Py_ForgetReference(PyObject *);
416-
PyAPI_FUNC(void) _Py_PrintReferences(FILE *);
417-
PyAPI_FUNC(void) _Py_PrintReferenceAddresses(FILE *);
418411
PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
419412
#else
420413
/* Without Py_TRACE_REFS, there's little enough to do that we expand code

Python/pylifecycle.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "pycore_initconfig.h"
1111
#include "pycore_fileutils.h"
1212
#include "pycore_hamt.h"
13+
#include "pycore_object.h"
1314
#include "pycore_pathconfig.h"
1415
#include "pycore_pyerrors.h"
1516
#include "pycore_pylifecycle.h"

Python/pythonrun.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "Python-ast.h"
1414
#undef Yield /* undefine macro conflicting with <winbase.h> */
15+
#include "pycore_object.h"
1516
#include "pycore_pyerrors.h"
1617
#include "pycore_pylifecycle.h"
1718
#include "pycore_pystate.h"

0 commit comments

Comments
 (0)
0