mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
bpo-35059: Convert _PyObject_GC_TRACK() to inline function (GH-10643)
* Add _PyObject_ASSERT_FROM() and _PyObject_ASSERT_FAILED_MSG() macros. * PyObject_GC_Track() now calls _PyObject_ASSERT_FAILED_MSG(), instead of Py_FatalError(), if the object is already tracked, to dump more information on error. * _PyObject_GC_TRACK() no longer checks if the object is already tracked at runtime, use an assertion instead for best performances; PyObject_GC_Track() still checks at runtime. * pycore_object.h now includes pycore_pystate.h. * Convert _PyObject_GC_TRACK() and _PyObject_GC_UNTRACK() macros to inline functions.
This commit is contained in:
parent
f1d002c1e0
commit
271753a27a
3 changed files with 68 additions and 42 deletions
|
|
@ -1846,15 +1846,16 @@ _PyGC_Dump(PyGC_Head *g)
|
|||
/* extension modules might be compiled with GC support so these
|
||||
functions must always be available */
|
||||
|
||||
#undef PyObject_GC_Track
|
||||
#undef PyObject_GC_UnTrack
|
||||
#undef PyObject_GC_Del
|
||||
#undef _PyObject_GC_Malloc
|
||||
|
||||
void
|
||||
PyObject_GC_Track(void *op)
|
||||
{
|
||||
_PyObject_GC_TRACK(op);
|
||||
PyObject *obj = (PyObject *)op;
|
||||
if (_PyObject_GC_IS_TRACKED(op)) {
|
||||
_PyObject_ASSERT_FAILED_MSG(op,
|
||||
"object already tracked "
|
||||
"by the garbage collector");
|
||||
}
|
||||
_PyObject_GC_TRACK(obj);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue