This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author christian.heimes
Recipients amaury.forgeotdarc, christian.heimes
Date 2008-10-31.21:37:40
SpamBayes Score 6.1874887e-09
Marked as misclassified No
Message-id <1225489062.5.0.646105339228.issue4233@psf.upfronthosting.co.za>
In-reply-to
Content
I don't see a good 'n easy way to fix the issue. close() is called in
too many places and I don't wanna add more checks in Python code. 

This patch reduces the mass of warnings to one, but it also changes the
semantic of close() a bit. However it seems logical to set the fd
attribute of the file object to -1 (meaning closed).

Index: Modules/_fileio.c
===================================================================
--- Modules/_fileio.c   (Revision 67068)
+++ Modules/_fileio.c   (Arbeitskopie)
@@ -60,7 +60,8 @@
 static PyObject *
 fileio_close(PyFileIOObject *self)
 {
-       if (!self->closefd) {
+       if (!self->closefd && self->fd >= 0) {
+               self->fd = -1;
                if (PyErr_WarnEx(PyExc_RuntimeWarning,
                                 "Trying to close unclosable fd!", 3) < 0) {
                        return NULL;
History
Date User Action Args
2008-10-31 21:37:42christian.heimessetrecipients: + christian.heimes, amaury.forgeotdarc
2008-10-31 21:37:42christian.heimessetmessageid: <1225489062.5.0.646105339228.issue4233@psf.upfronthosting.co.za>
2008-10-31 21:37:41christian.heimeslinkissue4233 messages
2008-10-31 21:37:40christian.heimescreate