]> granicus.if.org Git - python/commitdiff
bpo-35053: Define _PyTraceMalloc_NewReference in object.h (GH-10107)
authorVictor Stinner <vstinner@redhat.com>
Thu, 25 Oct 2018 22:01:56 +0000 (00:01 +0200)
committerGitHub <noreply@github.com>
Thu, 25 Oct 2018 22:01:56 +0000 (00:01 +0200)
_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.

Include/object.h
Include/tracemalloc.h
Modules/Setup

index 4a49609c72c3277f8b606729d497a12d809cdd68..2809d3af182fcbbebdc09fd376e460da4f887719 100644 (file)
@@ -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 *);
index cf5bb54ea08a13377a5327e121cb86824d56a059..bd14217c199c3cb212aa8253d1c32c0e53325b40 100644 (file)
@@ -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.
 
index a0622cc8c647cab13aaa3bdbc2669af2d15c6a0f..fb16698d2fc18eece2526d6bf549bf11a7887ff4 100644 (file)
@@ -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