Skip to content

Commit

Permalink
Use newer Py_TRASHCAN_BEGIN / Py_TRASHCAN_END if available
Browse files Browse the repository at this point in the history
  • Loading branch information
mdickinson committed Feb 1, 2024
1 parent d67f3b4 commit 41895c0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions traits/ctraits.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,10 +808,18 @@ static void
has_traits_dealloc(has_traits_object *obj)
{
PyObject_GC_UnTrack(obj);
#if PY_VERSION_HEX < 0x03080000
Py_TRASHCAN_SAFE_BEGIN(obj);
#else
Py_TRASHCAN_BEGIN(obj, has_traits_dealloc);
#endif
has_traits_clear(obj);
Py_TYPE(obj)->tp_free((PyObject *)obj);
#if PY_VERSION_HEX < 0x03080000
Py_TRASHCAN_SAFE_END(obj);
#else
Py_TRASHCAN_END
#endif
}

/*-----------------------------------------------------------------------------
Expand Down Expand Up @@ -3006,10 +3014,19 @@ static void
trait_dealloc(trait_object *trait)
{
PyObject_GC_UnTrack(trait);
#if PY_VERSION_HEX < 0x03080000
Py_TRASHCAN_SAFE_BEGIN(trait);
#else
Py_TRASHCAN_BEGIN(trait, trait_dealloc);
#endif
Py_TRASHCAN_SAFE_BEGIN(trait);
trait_clear(trait);
Py_TYPE(trait)->tp_free((PyObject *)trait);
#if PY_VERSION_HEX < 0x03080000
Py_TRASHCAN_SAFE_END(trait);
#else
Py_TRASHCAN_END
#endif
}

/*-----------------------------------------------------------------------------
Expand Down

0 comments on commit 41895c0

Please sign in to comment.