[Python-checkins] python/dist/src/Objects fileobject.c,2.192,2.193
astrand at users.sourceforge.net
astrand at users.sourceforge.net
Sun Nov 7 15:15:30 CET 2004
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv691
Modified Files:
fileobject.c
Log Message:
If close() fails in file_dealloc, then print an error message to
stderr. close() can fail if the user is out-of-quota, for example.
Fixes #959379.
Index: fileobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v
retrieving revision 2.192
retrieving revision 2.193
diff -u -d -r2.192 -r2.193
--- fileobject.c 11 Jun 2004 04:49:03 -0000 2.192
+++ fileobject.c 7 Nov 2004 14:15:28 -0000 2.193
@@ -300,12 +300,19 @@
static void
file_dealloc(PyFileObject *f)
{
+ int sts = 0;
if (f->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) f);
if (f->f_fp != NULL && f->f_close != NULL) {
Py_BEGIN_ALLOW_THREADS
- (*f->f_close)(f->f_fp);
+ sts = (*f->f_close)(f->f_fp);
Py_END_ALLOW_THREADS
+ if (sts == EOF)
+#ifdef HAVE_STRERROR
+ PySys_WriteStderr("close failed: [Errno %d] %s\n", errno, strerror(errno));
+#else
+ PySys_WriteStderr("close failed: [Errno %d]\n", errno);
+#endif
}
PyMem_Free(f->f_setbuf);
Py_XDECREF(f->f_name);
More information about the Python-checkins
mailing list