--- Python-2.5.4/Modules/pyexpat.c.orig 2009-01-07 20:20:46.000000000 -0800 +++ Python-2.5.4/Modules/pyexpat.c 2009-01-07 20:41:27.000000000 -0800 @@ -1005,6 +1005,12 @@ if (PyFile_Check(f)) { fp = PyFile_AsFile(f); + if (!fp) { + PyErr_Clear(); + PyErr_SetString(PyExc_ValueError, + "attempting to parse closed file"); + return NULL; + } } else { fp = NULL;