Skip to content

Commit c89a932

Browse files
authored
bpo-35053: Define _PyTraceMalloc_NewReference in object.h (GH-10107)
_PyTraceMalloc_NewReference() is now called by _Py_NewReference(), so move its definition to object.h. Moreover, define it even if Py_LIMITED_API is defined, since _Py_NewReference() is also exposed even if Py_LIMITED_API is defined.
1 parent 6c83d9f commit c89a932

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

Include/object.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,10 @@ PyAPI_FUNC(void) dec_count(PyTypeObject *);
765765
#define _Py_COUNT_ALLOCS_COMMA
766766
#endif /* COUNT_ALLOCS */
767767

768+
/* Update the Python traceback of an object. This function must be called
769+
when a memory block is reused from a free list. */
770+
PyAPI_FUNC(int) _PyTraceMalloc_NewReference(PyObject *op);
771+
768772
#ifdef Py_TRACE_REFS
769773
/* Py_TRACE_REFS is such major surgery that we call external routines. */
770774
PyAPI_FUNC(void) _Py_NewReference(PyObject *);

Include/tracemalloc.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ PyAPI_FUNC(int) PyTraceMalloc_Track(
1414
uintptr_t ptr,
1515
size_t size);
1616

17-
/* Update the Python traceback of an object.
18-
This function can be used when a memory block is reused from a free list. */
19-
PyAPI_FUNC(int) _PyTraceMalloc_NewReference(PyObject *op);
20-
2117
/* Untrack an allocated memory block in the tracemalloc module.
2218
Do nothing if the block was not tracked.
2319

Modules/Setup

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ _io -DPy_BUILD_CORE -I$(srcdir)/Modules/_io _io/_iomodule.c _io/iobase.c _io/fil
129129
faulthandler faulthandler.c
130130

131131
# debug tool to trace memory blocks allocated by Python
132+
#
133+
# bpo-35053: The module must be builtin since _Py_NewReference()
134+
# can call _PyTraceMalloc_NewReference().
132135
_tracemalloc _tracemalloc.c hashtable.c
133136

134137
# The rest of the modules listed in this file are all commented out by

0 commit comments

Comments
 (0)