From: Georg Brandl Date: Tue, 12 Aug 2008 08:47:02 +0000 (+0000) Subject: #3205: bz2 iterator fails silently on MemoryError X-Git-Tag: v2.5.3c1~65 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e71268f93fa7e33f87180e2895aec5a14505c9fb;p=python #3205: bz2 iterator fails silently on MemoryError (backport from r65609) --- diff --git a/Misc/NEWS b/Misc/NEWS index 79e7d41d56..475c9cbd48 100644 --- 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 diff --git a/Modules/bz2module.c b/Modules/bz2module.c index 7d33a77f12..9e868c5eb6 100644 --- a/Modules/bz2module.c +++ b/Modules/bz2module.c @@ -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