]> granicus.if.org Git - python/commitdiff
asyncio: Sync with github
authorYury Selivanov <yselivanov@sprymix.com>
Fri, 11 Dec 2015 16:32:59 +0000 (11:32 -0500)
committerYury Selivanov <yselivanov@sprymix.com>
Fri, 11 Dec 2015 16:32:59 +0000 (11:32 -0500)
Lib/asyncio/streams.py
Lib/test/test_asyncio/test_streams.py

index 6b5e96aea2c9caa559393f015ff1124a7eb41b0b..9097e38271de8d998d5ee56e51c26a01e93104eb 100644 (file)
@@ -494,6 +494,9 @@ class StreamReader:
 
     @coroutine
     def readexactly(self, n):
+        if n < 0:
+            raise ValueError('readexactly size can not be less than zero')
+
         if self._exception is not None:
             raise self._exception
 
index 6f657ad5f801ef3dee45013a8179b9bf560a7b03..b716a504de282360f32b7c482ecb31ec62c3ed74 100644 (file)
@@ -351,8 +351,8 @@ class StreamReaderTests(test_utils.TestCase):
         self.assertEqual(b'', data)
         self.assertEqual(self.DATA, stream._buffer)
 
-        data = self.loop.run_until_complete(stream.readexactly(-1))
-        self.assertEqual(b'', data)
+        with self.assertRaisesRegexp(ValueError, 'less than zero'):
+            self.loop.run_until_complete(stream.readexactly(-1))
         self.assertEqual(self.DATA, stream._buffer)
 
     def test_readexactly(self):