# HG changeset patch # Parent a444464a2e8710e77da1cca7e8e59ace44eab3c3 diff -r a444464a2e87 Doc/library/ssl.rst --- a/Doc/library/ssl.rst Thu May 14 18:47:17 2015 -0400 +++ b/Doc/library/ssl.rst Fri May 15 04:27:55 2015 +0000 @@ -844,7 +844,7 @@ SSL sockets also have the following additional methods and attributes: -.. method:: SSLSocket.read(len=0, buffer=None) +.. method:: SSLSocket.read(len=1024, buffer=None) Read up to *len* bytes of data from the SSL socket and return the result as a ``bytes`` instance. If *buffer* is specified, then read into the buffer diff -r a444464a2e87 Lib/ssl.py --- a/Lib/ssl.py Thu May 14 18:47:17 2015 -0400 +++ b/Lib/ssl.py Fri May 15 04:27:55 2015 +0000 @@ -560,7 +560,7 @@ server hostame is set.""" return self._sslobj.server_hostname - def read(self, len=0, buffer=None): + def read(self, len=1024, buffer=None): """Read up to 'len' bytes from the SSL object and return them. If 'buffer' is provided, read into this buffer and return the number of @@ -569,7 +569,7 @@ if buffer is not None: v = self._sslobj.read(len, buffer) else: - v = self._sslobj.read(len or 1024) + v = self._sslobj.read(len) return v def write(self, data): @@ -775,7 +775,7 @@ # EAGAIN. self.getpeername() - def read(self, len=0, buffer=None): + def read(self, len=1024, buffer=None): """Read up to LEN bytes and return them. Return zero-length string on EOF.""" diff -r a444464a2e87 Lib/test/test_ssl.py --- a/Lib/test/test_ssl.py Thu May 14 18:47:17 2015 -0400 +++ b/Lib/test/test_ssl.py Fri May 15 04:27:55 2015 +0000 @@ -2783,6 +2783,12 @@ self.assertRaises(NotImplementedError, s.recvmsg_into, bytearray(100)) + data = b"recv/read(0) should return no data" + s.send(data) + self.assertEqual(s.recv(0), b"") + self.assertEqual(s.read(0), b"") + self.assertEqual(s.read(), data) + s.write(b"over\n") s.close()