[Python-checkins] bpo-35053: Define _PyTraceMalloc_NewReference in object.h (GH-10107)

Victor Stinner webhook-mailer at python.org
Thu Oct 25 18:02:01 EDT 2018


https://github.com/python/cpython/commit/c89a93271447ec65e83a1dc7605e62dbf272cafd
commit: c89a93271447ec65e83a1dc7605e62dbf272cafd
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2018-10-26T00:01:56+02:00
summary:

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.

files:
M Include/object.h
M Include/tracemalloc.h
M Modules/Setup

diff --git a/Include/object.h b/Include/object.h
index 4a49609c72c3..2809d3af182f 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -765,6 +765,10 @@ PyAPI_FUNC(void) dec_count(PyTypeObject *);
 #define _Py_COUNT_ALLOCS_COMMA
 #endif /* COUNT_ALLOCS */
 
+/* Update the Python traceback of an object. This function must be called
+   when a memory block is reused from a free list. */
+PyAPI_FUNC(int) _PyTraceMalloc_NewReference(PyObject *op);
+
 #ifdef Py_TRACE_REFS
 /* Py_TRACE_REFS is such major surgery that we call external routines. */
 PyAPI_FUNC(void) _Py_NewReference(PyObject *);
diff --git a/Include/tracemalloc.h b/Include/tracemalloc.h
index cf5bb54ea08a..bd14217c199c 100644
--- a/Include/tracemalloc.h
+++ b/Include/tracemalloc.h
@@ -14,10 +14,6 @@ PyAPI_FUNC(int) PyTraceMalloc_Track(
     uintptr_t ptr,
     size_t size);
 
-/* Update the Python traceback of an object.
-   This function can be used when a memory block is reused from a free list. */
-PyAPI_FUNC(int) _PyTraceMalloc_NewReference(PyObject *op);
-
 /* Untrack an allocated memory block in the tracemalloc module.
    Do nothing if the block was not tracked.
 
diff --git a/Modules/Setup b/Modules/Setup
index a0622cc8c647..fb16698d2fc1 100644
--- a/Modules/Setup
+++ b/Modules/Setup
@@ -129,6 +129,9 @@ _io -DPy_BUILD_CORE -I$(srcdir)/Modules/_io _io/_iomodule.c _io/iobase.c _io/fil
 faulthandler faulthandler.c
 
 # debug tool to trace memory blocks allocated by Python
+#
+# bpo-35053: The module must be builtin since _Py_NewReference()
+# can call _PyTraceMalloc_NewReference().
 _tracemalloc _tracemalloc.c hashtable.c
 
 # The rest of the modules listed in this file are all commented out by



More information about the Python-checkins mailing list