]> granicus.if.org Git - python/commitdiff
#3205: bz2 iterator fails silently on MemoryError
authorGeorg Brandl <georg@python.org>
Tue, 12 Aug 2008 08:47:02 +0000 (08:47 +0000)
committerGeorg Brandl <georg@python.org>
Tue, 12 Aug 2008 08:47:02 +0000 (08:47 +0000)
(backport from r65609)

Misc/NEWS
Modules/bz2module.c

index 79e7d41d5622b2d6b9c022f79f4eb32e1a7af9fc..475c9cbd4813cf08b949e297f2dcacd83fd7f83e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -145,6 +145,9 @@ Library
 Extension Modules
 -----------------
 
+- Issue #3205: When iterating over a BZ2File fails allocating memory, raise
+  a MemoryError rather than silently stop the iteration.
+
 - Patch #2111: Avoid mmap segfault when modifying a PROT_READ block.
 
 - zlib.decompressobj().flush(value) no longer crashes the interpreter when
index 7d33a77f128d5738621bc37421962bd1222a89e4..9e868c5eb692b86e80fab9979771c4a6cf60a588 100644 (file)
@@ -416,6 +416,7 @@ Util_ReadAhead(BZ2FileObject *f, int bufsize)
                return 0;
        }
        if ((f->f_buf = PyMem_Malloc(bufsize)) == NULL) {
+               PyErr_NoMemory();
                return -1;
        }
        Py_BEGIN_ALLOW_THREADS