New submission from Michiel de Hoon <[EMAIL PROTECTED]>: PyMem_Malloc is called in the Util_ReadAhead function in bz2module.c. The code checks if PyMem_Malloc returns NULL, but in that case no MemoryError is raised. So, if in the following code:
>>> input = bz2.BZ2File("myfile.txt.bz2") >>> for line in input: ... # do something with the line Python runs out of memory during the for-loop, then the for-loop exits without an Exception being raised. To the user, it appears that the end of the myfile.txt.bz2 file was reached and that no error occurred. In the attached patch, I call PyErr_NoMemory() if PyMem_Malloc fails. This then raises the MemoryError exception as appropriate. ---------- components: Extension Modules files: bz2module.c.patch keywords: patch messages: 68770 nosy: mdehoon severity: normal status: open title: bz2 iterator fails silently on MemoryError type: behavior Added file: http://bugs.python.org/file10740/bz2module.c.patch _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3205> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com