summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-01-27 01:56:08 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-01-27 01:56:08 (GMT)
commit371c307e565e8c5b9b64e5902c735e347fe0a051 (patch)
treea600277d0e35c32ef2136f9c9f7c9783162407fe
parent0a8f347fbc548930bcb610aec4bf6a4459bf7991 (diff)
downloadcpython-371c307e565e8c5b9b64e5902c735e347fe0a051.zip
cpython-371c307e565e8c5b9b64e5902c735e347fe0a051.tar.gz
cpython-371c307e565e8c5b9b64e5902c735e347fe0a051.tar.bz2
Merged revisions 77781-77782 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r77781 | benjamin.peterson | 2010-01-26 19:47:14 -0600 (Tue, 26 Jan 2010) | 1 line don't accept bytes in FileIO.write #7785 ........ r77782 | benjamin.peterson | 2010-01-26 19:51:29 -0600 (Tue, 26 Jan 2010) | 1 line add issue number ........
-rw-r--r--Lib/test/test_fileio.py5
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/_io/fileio.c2
3 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py
index d8f6225..7a9b780 100644
--- a/Lib/test/test_fileio.py
+++ b/Lib/test/test_fileio.py
@@ -78,6 +78,9 @@ class AutoFileTests(unittest.TestCase):
self.assertEqual(self.f.readline(None), b"hi\n")
self.assertEqual(self.f.readlines(None), [b"bye\n", b"abc"])
+ def test_reject(self):
+ self.assertRaises(TypeError, self.f.write, "Hello!")
+
def testRepr(self):
self.assertEquals(repr(self.f), "<_io.FileIO name=%r mode=%r>"
% (self.f.name, self.f.mode))
@@ -170,7 +173,7 @@ class AutoFileTests(unittest.TestCase):
@ClosedFDRaises
def testErrnoOnClosedWrite(self, f):
- f.write('a')
+ f.write(b'a')
@ClosedFDRaises
def testErrnoOnClosedSeek(self, f):
diff --git a/Misc/NEWS b/Misc/NEWS
index befc61c..2a66d01 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -73,6 +73,8 @@ Core and Builtins
Library
-------
+- Issue #7785: Don't accept bytes in FileIO.write().
+
- Issue #7773: Fix an UnboundLocalError in platform.linux_distribution() when
the release file is empty.
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index 8162396..d04a74d 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -651,7 +651,7 @@ fileio_write(fileio *self, PyObject *args)
if (!self->writable)
return err_mode("writing");
- if (!PyArg_ParseTuple(args, "s*", &pbuf))
+ if (!PyArg_ParseTuple(args, "y*", &pbuf))
return NULL;
if (_PyVerify_fd(self->fd)) {