Skip to content
Merged
Prev Previous commit
Next Next commit
Pass a flag to _release_xid_data().
  • Loading branch information
ericsnowcurrently committed Sep 9, 2023
commit 53e102912576e847e7d1135fee4636fd66b8937c
9 changes: 6 additions & 3 deletions Modules/_xxinterpchannelsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,12 @@ add_new_type(PyObject *mod, PyType_Spec *spec, crossinterpdatafunc shared)
return cls;
}

#define XID_IGNORE_EXC 1

static int
_release_xid_data(_PyCrossInterpreterData *data, int ignoreexc)
_release_xid_data(_PyCrossInterpreterData *data, int flags)
{
int ignoreexc = flags & XID_IGNORE_EXC;
PyObject *exc;
if (ignoreexc) {
exc = PyErr_GetRaisedException();
Expand Down Expand Up @@ -366,7 +369,7 @@ static void
_channelitem_clear(_channelitem *item)
{
if (item->data != NULL) {
(void)_release_xid_data(item->data, 1);
(void)_release_xid_data(item->data, XID_IGNORE_EXC);
// It was allocated in _channel_send().
GLOBAL_FREE(item->data);
item->data = NULL;
Expand Down Expand Up @@ -1439,7 +1442,7 @@ _channel_recv(_channels *channels, int64_t id, PyObject **res)
PyObject *obj = _PyCrossInterpreterData_NewObject(data);
if (obj == NULL) {
assert(PyErr_Occurred());
(void)_release_xid_data(data, 1);
(void)_release_xid_data(data, XID_IGNORE_EXC);
// It was allocated in _channel_send().
GLOBAL_FREE(data);
return -1;
Expand Down