diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-11-22 00:02:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-22 00:02:54 (GMT) |
commit | 271753a27aca2e13275f0827080b915fb438107a (patch) | |
tree | 63bb4ea49b621175c73e6a696466e5ef997ba911 /Modules | |
parent | f1d002c1e094922b0f17a820f90ff102d68ab253 (diff) | |
download | cpython-271753a27aca2e13275f0827080b915fb438107a.zip cpython-271753a27aca2e13275f0827080b915fb438107a.tar.gz cpython-271753a27aca2e13275f0827080b915fb438107a.tar.bz2 |
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.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/gcmodule.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index 2cbf738..506ae19 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -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 |