Author mdehoon
Recipients mdehoon
Date 2008-06-26.09:08:19
SpamBayes Score 0.00268456
Marked as misclassified No
Message-id <>
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.
Date User Action Args
2008-06-26 09:08:22mdehoonsetspambayes_score: 0.00268456 -> 0.00268456
recipients: + mdehoon
2008-06-26 09:08:21mdehoonsetspambayes_score: 0.00268456 -> 0.00268456
messageid: <>
2008-06-26 09:08:20mdehoonlinkissue3205 messages
2008-06-26 09:08:19mdehooncreate