summaryrefslogtreecommitdiffstats
path: root/Objects/fileobject.c
diff options
context:
space:
mode:
authorPeter Astrand <astrand@lysator.liu.se>2004-11-07 14:15:28 (GMT)
committerPeter Astrand <astrand@lysator.liu.se>2004-11-07 14:15:28 (GMT)
commitf8e74b12b00401b9cd6322fc339a1b9111e944df (patch)
tree51c81e79cb15554e54ca3a0deb5ad2645f5aeeed /Objects/fileobject.c
parent4f802ac2b6dfbf28de270dafcf11f8d71a607b81 (diff)
downloadcpython-f8e74b12b00401b9cd6322fc339a1b9111e944df.zip
cpython-f8e74b12b00401b9cd6322fc339a1b9111e944df.tar.gz
cpython-f8e74b12b00401b9cd6322fc339a1b9111e944df.tar.bz2
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.
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r--Objects/fileobject.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 34f28e3..c08345c 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -300,12 +300,19 @@ static void drop_readahead(PyFileObject *);
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);