class TestBase(unittest.TestCase):
+ def pipe(self):
+ def ensure_closed(fd):
+ try:
+ os.close(fd)
+ except OSError:
+ pass
+ r, w = os.pipe()
+ self.addCleanup(lambda: ensure_closed(r))
+ self.addCleanup(lambda: ensure_closed(w))
+ return r, w
+
def tearDown(self):
clean_up_interpreters()
self.assertFalse(interp.is_running())
def test_finished(self):
- r, w = os.pipe()
+ r, w = self.pipe()
interp = interpreters.create()
interp.run(f"""if True:
import os
interp.is_running()
def test_with_only_background_threads(self):
- r_interp, w_interp = os.pipe()
- r_thread, w_thread = os.pipe()
+ r_interp, w_interp = self.pipe()
+ r_thread, w_thread = self.pipe()
DONE = b'D'
FINISHED = b'F'
self.assertTrue(interp.is_running())
def test_subthreads_still_running(self):
- r_interp, w_interp = os.pipe()
- r_thread, w_thread = os.pipe()
+ r_interp, w_interp = self.pipe()
+ r_thread, w_thread = self.pipe()
FINISHED = b'F'
interp.run(b'print("spam")')
def test_with_background_threads_still_running(self):
- r_interp, w_interp = os.pipe()
- r_thread, w_thread = os.pipe()
+ r_interp, w_interp = self.pipe()
+ r_thread, w_thread = self.pipe()
RAN = b'R'
DONE = b'D'
after = set(interpreters.list_all_channels())
self.assertEqual(after, created)
+ @unittest.expectedFailure # See gh-110318:
def test_shareable(self):
rch, sch = interpreters.create_channel()
return NULL;
}
}
+ Py_DECREF(highlevel);
if (end == CHANNEL_SEND) {
cls = state->send_channel_type;
}
}
PyTypeObject *cls = _get_current_channel_end_type(cid->end);
if (cls == NULL) {
+ Py_DECREF(cid);
return NULL;
}
PyObject *obj = PyObject_CallOneArg((PyObject *)cls, (PyObject *)cid);
if (cidobj == NULL) {
return -1;
}
- if (_channelid_shared(tstate, cidobj, data) < 0) {
+ int res = _channelid_shared(tstate, cidobj, data);
+ Py_DECREF(cidobj);
+ if (res < 0) {
return -1;
}
data->new_object = _channel_end_from_xid;
return NULL;
}
PyTypeObject *cls = state->ChannelIDType;
- assert(get_module_from_owned_type(cls) == self);
+
+ PyObject *mod = get_module_from_owned_type(cls);
+ assert(mod == self);
+ Py_DECREF(mod);
return _channelid_new(self, cls, args, kwds);
}