Message 320307 - Python tracker
It seems like Python 2.7 is inaffected by the bug:
static int
BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs)
{
...
#ifdef WITH_THREAD
if (!self->lock) {
self->lock = PyThread_allocate_lock();
}
if (!self->lock) {
PyErr_SetString(PyExc_MemoryError, "unable to allocate lock");
goto error;
}
#endif
...
}
I fixed the leak in Python 3.6, 3.7 and master. I close the issue.