[Python-checkins] r68747 - in python/branches/io-c: Lib/test/test_io.py Modules/_iobase.c

antoine.pitrou python-checkins at python.org
Sun Jan 18 23:35:58 CET 2009


Author: antoine.pitrou
Date: Sun Jan 18 23:35:58 2009
New Revision: 68747

Log:
Kill test failure



Modified:
   python/branches/io-c/Lib/test/test_io.py
   python/branches/io-c/Modules/_iobase.c

Modified: python/branches/io-c/Lib/test/test_io.py
==============================================================================
--- python/branches/io-c/Lib/test/test_io.py	(original)
+++ python/branches/io-c/Lib/test/test_io.py	Sun Jan 18 23:35:58 2009
@@ -1809,7 +1809,8 @@
             self.assertRaises(ValueError, f.seek, 0)
             self.assertRaises(ValueError, f.tell)
             self.assertRaises(ValueError, f.truncate)
-            self.assertRaises(ValueError, f.write, "")
+            self.assertRaises(ValueError, f.write,
+                              b"" if "b" in kwargs['mode'] else "")
             self.assertRaises(ValueError, f.writelines, [])
 
 

Modified: python/branches/io-c/Modules/_iobase.c
==============================================================================
--- python/branches/io-c/Modules/_iobase.c	(original)
+++ python/branches/io-c/Modules/_iobase.c	Sun Jan 18 23:35:58 2009
@@ -105,6 +105,10 @@
 IOBase_flush(PyObject *self, PyObject *args)
 {
     /* XXX Should this return the number of bytes written??? */
+    if (IS_CLOSED(self)) {
+        PyErr_SetString(PyExc_ValueError, "I/O operation on closed file.");
+        return NULL;
+    }
     Py_RETURN_NONE;
 }
 
@@ -132,7 +136,6 @@
     return PyBool_FromLong(IS_CLOSED(self));
 }
 
-
 PyObject *
 _PyIOBase_checkClosed(PyObject *self, PyObject *args)
 {
@@ -171,10 +174,14 @@
     Py_RETURN_NONE;
 }
 
+/* Destructor */
+
 static PyObject *
 IOBase_del(PyObject *self, PyObject *args)
 {
     PyObject *res = NULL;
+    if (IOBase_closed(self))
+        Py_RETURN_NONE;
     res = PyObject_CallMethodObjArgs(self, _PyIO_str_close, NULL);
     if (res == NULL) {
         /* At program exit time, it's possible that globals have already been


More information about the Python-checkins mailing list