Skip to content
Prev Previous commit
Next Next commit
Use _get_current_channel_end_type() in _channel_from_cid().
  • Loading branch information
ericsnowcurrently committed Sep 29, 2023
commit b3f29ceaa82074e3fba6c3e77e14520ced7921b6
15 changes: 3 additions & 12 deletions Modules/_xxinterpchannelsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1803,21 +1803,12 @@ channelid_richcompare(PyObject *self, PyObject *other, int op)
return res;
}

static PyTypeObject * _get_current_channel_end_type(int end);

static PyObject *
_channel_from_cid(PyObject *cid, int end)
{
PyObject *highlevel = PyImport_ImportModule("interpreters");
if (highlevel == NULL) {
PyErr_Clear();
highlevel = PyImport_ImportModule("test.support.interpreters");
if (highlevel == NULL) {
return NULL;
}
}
const char *clsname = (end == CHANNEL_RECV) ? "RecvChannel" :
"SendChannel";
PyObject *cls = PyObject_GetAttrString(highlevel, clsname);
Py_DECREF(highlevel);
PyObject *cls = (PyObject *)_get_current_channel_end_type(end);
if (cls == NULL) {
return NULL;
}
Expand Down