]> granicus.if.org Git - python/commitdiff
Applying patch #728656, by logistix, fixing opening of nonexistent
authorGustavo Niemeyer <gustavo@niemeyer.net>
Tue, 29 Apr 2003 14:53:08 +0000 (14:53 +0000)
committerGustavo Niemeyer <gustavo@niemeyer.net>
Tue, 29 Apr 2003 14:53:08 +0000 (14:53 +0000)
bz2 files. Also, included a testcase for this problem.

Lib/test/test_bz2.py
Modules/bz2module.c

index 9134aae55ebd01a49e03b5bf055c1808593d6040..64ce6abaaffc929c8a1ea482cd6f500cec8dd491 100644 (file)
@@ -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()"
index 1fb6665085bb531520f41aee6b07392f99b824d6..9289a02b238dde08c4cbb290666833fae842c885 100644 (file)
@@ -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);
 }