Applying patch #728656, by logistix, fixing opening of nonexistent
bz2 files. Also, included a testcase for this problem.
diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py
index 9134aae..64ce6ab 100644
--- a/Lib/test/test_bz2.py
+++ b/Lib/test/test_bz2.py
@@ -219,11 +219,16 @@
bz2f.close()
def testOpenDel(self):
+ # "Test opening and deleting a file many times"
self.createTempFile()
for i in xrange(10000):
o = BZ2File(self.filename)
del o
+ def testOpenNonexistent(self):
+ # "Test opening a nonexistent file"
+ self.assertRaises(IOError, BZ2File, "/non/existent")
+
class BZ2CompressorTest(BaseTest):
def testCompress(self):
# "Test BZ2Compressor.compress()/flush()"
diff --git a/Modules/bz2module.c b/Modules/bz2module.c
index 1fb6665..9289a02 100644
--- a/Modules/bz2module.c
+++ b/Modules/bz2module.c
@@ -1388,7 +1388,7 @@
break;
}
Util_DropReadAhead(self);
- Py_DECREF(self->file);
+ Py_XDECREF(self->file);
self->ob_type->tp_free((PyObject *)self);
}