summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-01-08 14:21:28 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-01-08 14:21:28 (GMT)
commit57ddf78b6b18d9da6f466b4e6da0437c3271196e (patch)
treecf55257edc004a09f62e19d67668e30634f17712 /Lib
parent2bcbc141173e5cd2ed36693a71bed8d5a1a54dd4 (diff)
downloadcpython-57ddf78b6b18d9da6f466b4e6da0437c3271196e.zip
cpython-57ddf78b6b18d9da6f466b4e6da0437c3271196e.tar.gz
cpython-57ddf78b6b18d9da6f466b4e6da0437c3271196e.tar.bz2
Issue #20113: os.readv() and os.writev() now raise an OSError exception on
error instead of returning -1.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_os.py9
-rw-r--r--Lib/test/test_posix.py10
2 files changed, 18 insertions, 1 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index b5bfe94..d70a0ae 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -1227,6 +1227,11 @@ class TestInvalidFD(unittest.TestCase):
def test_read(self):
self.check(os.read, 1)
+ @unittest.skipUnless(hasattr(os, 'readv'), 'test needs os.readv()')
+ def test_readv(self):
+ buf = bytearray(10)
+ self.check(os.readv, [buf])
+
@unittest.skipUnless(hasattr(os, 'tcsetpgrp'), 'test needs os.tcsetpgrp()')
def test_tcsetpgrpt(self):
self.check(os.tcsetpgrp, 0)
@@ -1235,6 +1240,10 @@ class TestInvalidFD(unittest.TestCase):
def test_write(self):
self.check(os.write, b" ")
+ @unittest.skipUnless(hasattr(os, 'writev'), 'test needs os.writev()')
+ def test_writev(self):
+ self.check(os.writev, [b'abc'])
+
class LinkTests(unittest.TestCase):
def setUp(self):
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 02bb6ac..5e680c9 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -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)