don't accept bytes in FileIO.write #7785
This commit is contained in:
parent
d8aef76f6e
commit
255058fae3
@ -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))
|
||||
@ -168,7 +171,7 @@ class AutoFileTests(unittest.TestCase):
|
||||
|
||||
@ClosedFDRaises
|
||||
def testErrnoOnClosedWrite(self, f):
|
||||
f.write('a')
|
||||
f.write(b'a')
|
||||
|
||||
@ClosedFDRaises
|
||||
def testErrnoOnClosedSeek(self, f):
|
||||
|
@ -234,6 +234,8 @@ C-API
|
||||
Library
|
||||
-------
|
||||
|
||||
- Don't accept bytes in FileIO.write().
|
||||
|
||||
- Removed the functions 'verify' and 'vereq' from Lib/test/support.py.
|
||||
|
||||
- Issue #7773: Fix an UnboundLocalError in platform.linux_distribution() when
|
||||
|
@ -648,7 +648,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)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user