This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mdehoon
Recipients mdehoon
Date 2008-06-26.09:08:19
SpamBayes Score 0.0026845639
Marked as misclassified No
Message-id <1214471301.68.0.267247122126.issue3205@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2008-06-26 09:08:22mdehoonsetspambayes_score: 0.00268456 -> 0.0026845639
recipients: + mdehoon
2008-06-26 09:08:21mdehoonsetspambayes_score: 0.00268456 -> 0.00268456
messageid: <1214471301.68.0.267247122126.issue3205@psf.upfronthosting.co.za>
2008-06-26 09:08:20mdehoonlinkissue3205 messages
2008-06-26 09:08:19mdehooncreate