Index: Modules/pyexpat.c =================================================================== --- Modules/pyexpat.c (revision 83828) +++ Modules/pyexpat.c (working copy) @@ -855,11 +855,9 @@ xmlparse_ParseFile(xmlparseobject *self, PyObject *f) { int rv = 1; - FILE *fp; PyObject *readmethod = NULL; { - fp = NULL; readmethod = PyObject_GetAttrString(f, "read"); if (readmethod == NULL) { PyErr_Clear(); @@ -876,20 +874,11 @@ return PyErr_NoMemory(); } - if (fp) { - bytes_read = fread(buf, sizeof(char), BUF_SIZE, fp); - if (bytes_read < 0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } + bytes_read = readinst(buf, BUF_SIZE, readmethod); + if (bytes_read < 0) { + Py_DECREF(readmethod); + return NULL; } - else { - bytes_read = readinst(buf, BUF_SIZE, readmethod); - if (bytes_read < 0) { - Py_DECREF(readmethod); - return NULL; - } - } rv = XML_ParseBuffer(self->itself, bytes_read, bytes_read == 0); if (PyErr_Occurred()) { Py_XDECREF(readmethod);