(Merge 3.3) Issue #20113: os.readv() and os.writev() now raise an OSError

exception on error instead of returning -1.
This commit is contained in:
Victor Stinner 2014-01-08 15:26:12 +01:00
commit 149e540adf
4 changed files with 36 additions and 10 deletions

View file

@ -283,9 +283,14 @@ class PosixTester(unittest.TestCase):
def test_writev(self):
fd = os.open(support.TESTFN, os.O_RDWR | os.O_CREAT)
try:
os.writev(fd, (b'test1', b'tt2', b't3'))
n = os.writev(fd, (b'test1', b'tt2', b't3'))
self.assertEqual(n, 10)
os.lseek(fd, 0, os.SEEK_SET)
self.assertEqual(b'test1tt2t3', posix.read(fd, 10))
# Issue #20113: empty list of buffers should not crash
self.assertEqual(posix.writev(fd, []), 0)
finally:
os.close(fd)
@ -298,6 +303,9 @@ class PosixTester(unittest.TestCase):
buf = [bytearray(i) for i in [5, 3, 2]]
self.assertEqual(posix.readv(fd, buf), 10)
self.assertEqual([b'test1', b'tt2', b't3'], [bytes(i) for i in buf])
# Issue #20113: empty list of buffers should not crash
self.assertEqual(posix.readv(fd, []), 0)
finally:
os.close(fd)