diff --git a/python/lib/pythontarget.c b/python/lib/pythontarget.c index 77dcdebcf..47baa685a 100644 --- a/python/lib/pythontarget.c +++ b/python/lib/pythontarget.c @@ -437,7 +437,7 @@ void destroy_action_capsule(PyObject* capsule) { PyObject* convert_C_port_to_py(void* port, int width) { // Create the port struct in Python PyObject* cap = - (PyObject*)PyObject_New(generic_port_capsule_struct, &py_port_capsule_t); + (PyObject*)PyObject_GC_New(generic_port_capsule_struct, &py_port_capsule_t); if (cap == NULL) { lf_print_error_and_exit("Failed to convert port."); } @@ -506,7 +506,7 @@ PyObject* convert_C_action_to_py(void* action) { trigger_t* trigger = ((lf_action_base_t*)action)->trigger; // Create the action struct in Python - PyObject* cap = (PyObject*)PyObject_New(generic_action_capsule_struct, &py_action_capsule_t); + PyObject* cap = (PyObject*)PyObject_GC_New(generic_action_capsule_struct, &py_action_capsule_t); if (cap == NULL) { lf_print_error_and_exit("Failed to convert action."); }