From 572f5233f0263ab75782bbce4bd67259d73e32ac Mon Sep 17 00:00:00 2001 From: Gustavo Niemeyer Date: Tue, 29 Apr 2003 14:53:08 +0000 Subject: Applying patch #728656, by logistix, fixing opening of nonexistent bz2 files. Also, included a testcase for this problem. --- Lib/test/test_bz2.py | 5 +++++ Modules/bz2module.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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 @@ class BZ2FileTest(BaseTest): 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 @@ BZ2File_dealloc(BZ2FileObject *self) break; } Util_DropReadAhead(self); - Py_DECREF(self->file); + Py_XDECREF(self->file); self->ob_type->tp_free((PyObject *)self); } -- cgit v0.12