Bug #1177964: make file iterator raise MemoryError on too big files
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 29c89db..5a50d1e 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -1797,7 +1797,7 @@
 
 /* Make sure that file has a readahead buffer with at least one byte
    (unless at EOF) and no more than bufsize.  Returns negative value on
-   error */
+   error, will set MemoryError if bufsize bytes cannot be allocated. */
 static int
 readahead(PyFileObject *f, int bufsize)
 {
@@ -1810,6 +1810,7 @@
 			drop_readahead(f);
 	}
 	if ((f->f_buf = PyMem_Malloc(bufsize)) == NULL) {
+		PyErr_NoMemory();
 		return -1;
 	}
 	Py_BEGIN_ALLOW_THREADS