Skip to content

Commit 498ace9

Browse files
committed
Use Py_IsFinalizing starting from Python 3.13
Signed-off-by: Erik Boasson <[email protected]>
1 parent 309c269 commit 498ace9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

clayer/pysertype.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,15 @@ static void sertype_free (struct ddsi_sertype *tpcmn)
487487
dds_free (this->typemap_ser_data);
488488
dds_cdrstream_desc_fini (&this->cdrstream_desc, &cdrstream_allocator);
489489

490-
// dds_free the python type if python isn't already shutting down (deadlock).
491-
#if PY_MINOR_VERSION > 6
490+
// dds_free the python type if python isn't already shutting down (deadlock).#
491+
#if PY_MINOR_VERSION >= 13
492+
if (!Py_IsFinalizing ())
493+
{
494+
PyGILState_STATE state = PyGILState_Ensure ();
495+
Py_DECREF (this->my_py_type);
496+
PyGILState_Release (state);
497+
}
498+
#elif PY_MINOR_VERSION > 6
492499
if (!_Py_IsFinalizing ())
493500
{
494501
PyGILState_STATE state = PyGILState_Ensure ();

0 commit comments

Comments
 (0)