[Python-checkins] r64767 - in python/trunk: Lib/test/test_bz2.py Misc/NEWS Modules/bz2module.c

gregory.p.smith python-checkins at python.org
Mon Jul 7 06:31:59 CEST 2008


Author: gregory.p.smith
Date: Mon Jul 7 06:31:58 2008
New Revision: 64767
Log:
- Issue #3309: Fix bz2.BZFile itererator to release its internal lock
 properly when raising an exception due to the bz2file being closed.
 Prevents a deadlock.
Modified:
 python/trunk/Lib/test/test_bz2.py
 python/trunk/Misc/NEWS
 python/trunk/Modules/bz2module.c
Modified: python/trunk/Lib/test/test_bz2.py
==============================================================================
--- python/trunk/Lib/test/test_bz2.py	(original)
+++ python/trunk/Lib/test/test_bz2.py	Mon Jul 7 06:31:58 2008
@@ -112,6 +112,17 @@
 self.assertEqual(list(iter(bz2f)), sio.readlines())
 bz2f.close()
 
+ def testClosedIteratorDeadlock(self):
+ # "Test that iteration on a closed bz2file releases the lock."
+ # http://bugs.python.org/issue3309
+ self.createTempFile()
+ bz2f = BZ2File(self.filename)
+ bz2f.close()
+ self.assertRaises(ValueError, bz2f.next)
+ # This call will deadlock of the above .next call failed to
+ # release the lock.
+ self.assertRaises(ValueError, bz2f.readlines)
+
 def testXReadLines(self):
 # "Test BZ2File.xreadlines()"
 self.createTempFile()
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Mon Jul 7 06:31:58 2008
@@ -68,6 +68,10 @@
 - Issue #2113: Fix error in subprocess.Popen if the select system call is
 interrupted by a signal.
 
+- Issue #3309: Fix bz2.BZFile itererator to release its internal lock
+ properly when raising an exception due to the bz2file being closed.
+ Prevents a deadlock.
+
 Build
 -----
 
Modified: python/trunk/Modules/bz2module.c
==============================================================================
--- python/trunk/Modules/bz2module.c	(original)
+++ python/trunk/Modules/bz2module.c	Mon Jul 7 06:31:58 2008
@@ -1451,6 +1451,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;


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /