summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2006-03-15 22:13:13 +0000
committerWalter Dörwald <walter@livinglogic.de>2006-03-15 22:13:13 +0000
commitb86f98c6d24a9f3d833931ce343d5ac2c2921818 (patch)
tree53d1bb450d081f509ae6b95d78852c7b4dbdb01a
parent1744d9b92d81b42dd04c851db4897df46b2986b7 (diff)
downloadcpython-b86f98c6d24a9f3d833931ce343d5ac2c2921818.tar.gz
SF patch #1359365: cStringIO.StringIO.isatty() will raise a ValueError
now if close() has been called before (like file and StringIO.StringIO do)
-rw-r--r--Lib/test/test_StringIO.py7
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/cStringIO.c3
3 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_StringIO.py b/Lib/test/test_StringIO.py
index a2e544458b..cc3367fed8 100644
--- a/Lib/test/test_StringIO.py
+++ b/Lib/test/test_StringIO.py
@@ -75,6 +75,13 @@ class TestGenericStringIO(unittest.TestCase):
f.close()
self.assertEqual(f.closed, True)
+ def test_isatty(self):
+ f = self.MODULE.StringIO()
+ self.assertRaises(TypeError, f.isatty, None)
+ self.assertEqual(f.isatty(), False)
+ f.close()
+ self.assertRaises(ValueError, f.isatty)
+
def test_iterator(self):
eq = self.assertEqual
unless = self.failUnless
diff --git a/Misc/NEWS b/Misc/NEWS
index 47da68c173..820ae4a481 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -449,6 +449,9 @@ Library
codecs.getincrementaldecoder() and codecs.getincrementalencoder() have
been added.
+- SF patch #1359365: cStringIO.StringIO.isatty() will raise a ValueError
+ now if close() has been called before (like file and StringIO.StringIO do)
+
- A regrtest option -w was added to re-run failed tests in verbose mode.
- Patch #1446372: quit and exit can now be called from the interactive
diff --git a/Modules/cStringIO.c b/Modules/cStringIO.c
index fd28aa9324..bdc9f00d39 100644
--- a/Modules/cStringIO.c
+++ b/Modules/cStringIO.c
@@ -144,7 +144,8 @@ PyDoc_STRVAR(IO_isatty__doc__, "isatty(): always returns 0");
static PyObject *
IO_isatty(IOobject *self, PyObject *unused) {
- Py_INCREF(Py_False);
+ if (!IO__opencheck(self)) return NULL;
+ Py_INCREF(Py_False);
return Py_False;
}