diff options
Diffstat (limited to 'Modules/arraymodule.c')
-rw-r--r-- | Modules/arraymodule.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 403f646..5b37896 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -1228,8 +1228,14 @@ array_fromfile(arrayobject *self, PyObject *args) PyMem_RESIZE(item, char, Py_SIZE(self)*itemsize); self->ob_item = item; self->allocated = Py_SIZE(self); - PyErr_SetString(PyExc_EOFError, - "not enough items in file"); + if (ferror(fp)) { + PyErr_SetFromErrno(PyExc_IOError); + clearerr(fp); + } + else { + PyErr_SetString(PyExc_EOFError, + "not enough items in file"); + } return NULL; } } |