[Python-checkins] r84809 - in python/branches/release31-maint: Lib/ssl.py Lib/test/test_ssl.py Misc/NEWS

antoine.pitrou python-checkins at python.org
Tue Sep 14 16:47:09 CEST 2010


Author: antoine.pitrou
Date: Tue Sep 14 16:47:08 2010
New Revision: 84809

Log:
Merged revisions 84807 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r84807 | antoine.pitrou | 2010-09-14 16:43:44 +0200 (mar., 14 sept. 2010) | 4 lines
  
  Issue #9853: Fix the signature of SSLSocket.recvfrom() and
  SSLSocket.sendto() to match the corresponding socket methods.
........


Modified:
   python/branches/release31-maint/   (props changed)
   python/branches/release31-maint/Lib/ssl.py
   python/branches/release31-maint/Lib/test/test_ssl.py
   python/branches/release31-maint/Misc/NEWS

Modified: python/branches/release31-maint/Lib/ssl.py
==============================================================================
--- python/branches/release31-maint/Lib/ssl.py	(original)
+++ python/branches/release31-maint/Lib/ssl.py	Tue Sep 14 16:47:08 2010
@@ -221,13 +221,15 @@
         else:
             return socket.send(self, data, flags)
 
-    def sendto(self, data, addr, flags=0):
+    def sendto(self, data, flags_or_addr, addr=None):
         self._checkClosed()
         if self._sslobj:
             raise ValueError("sendto not allowed on instances of %s" %
                              self.__class__)
+        elif addr is None:
+            return socket.sendto(self, data, flags_or_addr)
         else:
-            return socket.sendto(self, data, addr, flags)
+            return socket.sendto(self, data, flags_or_addr, addr)
 
     def sendall(self, data, flags=0):
         self._checkClosed()
@@ -267,13 +269,13 @@
         else:
             return socket.recv_into(self, buffer, nbytes, flags)
 
-    def recvfrom(self, addr, buflen=1024, flags=0):
+    def recvfrom(self, buflen=1024, flags=0):
         self._checkClosed()
         if self._sslobj:
             raise ValueError("recvfrom not allowed on instances of %s" %
                              self.__class__)
         else:
-            return socket.recvfrom(self, addr, buflen, flags)
+            return socket.recvfrom(self, buflen, flags)
 
     def recvfrom_into(self, buffer, nbytes=None, flags=0):
         self._checkClosed()

Modified: python/branches/release31-maint/Lib/test/test_ssl.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_ssl.py	(original)
+++ python/branches/release31-maint/Lib/test/test_ssl.py	Tue Sep 14 16:47:08 2010
@@ -92,6 +92,18 @@
         del ss
         self.assertEqual(wr(), None)
 
+    def test_wrapped_unconnected(self):
+        # Methods on an unconnected SSLSocket propagate the original
+        # socket.error raise by the underlying socket object.
+        s = socket.socket(socket.AF_INET)
+        ss = ssl.wrap_socket(s)
+        self.assertRaises(socket.error, ss.recv, 1)
+        self.assertRaises(socket.error, ss.recv_into, bytearray(b'x'))
+        self.assertRaises(socket.error, ss.recvfrom, 1)
+        self.assertRaises(socket.error, ss.recvfrom_into, bytearray(b'x'), 1)
+        self.assertRaises(socket.error, ss.send, b'x')
+        self.assertRaises(socket.error, ss.sendto, b'x', ('0.0.0.0', 0))
+
     def test_timeout(self):
         # Issue #8524: when creating an SSL socket, the timeout of the
         # original socket should be retained.

Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS	(original)
+++ python/branches/release31-maint/Misc/NEWS	Tue Sep 14 16:47:08 2010
@@ -117,6 +117,9 @@
 Library
 -------
 
+- Issue #9853: Fix the signature of SSLSocket.recvfrom() and
+  SSLSocket.sendto() to match the corresponding socket methods.
+
 - Issue #9792: In case of connection failure, socket.create_connection()
   would swallow the exception and raise a new one, making it impossible
   to fetch the original errno, or to filter timeout errors.  Now the


More information about the Python-checkins mailing list