Backport of r64767 from trunk
Fixes Issue #3309: Fix bz2.BZFile iterator to release its internal lock
properly when raising an exception due to the bz2file being closed.
Prevents a deadlock.
diff --git a/Modules/bz2module.c b/Modules/bz2module.c
index 9e868c5..73de628 100644
--- a/Modules/bz2module.c
+++ b/Modules/bz2module.c
@@ -1437,6 +1437,7 @@
PyStringObject* ret;
ACQUIRE_LOCK(self);
if (self->mode == MODE_CLOSED) {
+ RELEASE_LOCK(self);
PyErr_SetString(PyExc_ValueError,
"I/O operation on closed file");
return NULL;