]> granicus.if.org Git - python/commitdiff
Issue #25951: Fix SSLSocket.sendall() to return None, by Aviv Palivoda
authorMartin Panter <vadmium+py@gmail.com>
Sun, 3 Apr 2016 02:12:54 +0000 (02:12 +0000)
committerMartin Panter <vadmium+py@gmail.com>
Sun, 3 Apr 2016 02:12:54 +0000 (02:12 +0000)
Lib/ssl.py
Lib/test/test_ssl.py
Misc/NEWS

index 65ad38f899ed4660fe21c20dc9ce6091803e5301..68db748aa8fd14885773885e36d4645546548160 100644 (file)
@@ -886,7 +886,6 @@ class SSLSocket(socket):
             while (count < amount):
                 v = self.send(data[count:])
                 count += v
-            return amount
         else:
             return socket.sendall(self, data, flags)
 
index e0f231c0ab6f9f7e33a0034a5f8bf9b7e948a67d..00d437a951c5e44bc4d44d52fd0808a65cfb4fea 100644 (file)
@@ -2709,12 +2709,13 @@ if _have_threads:
                     count, addr = s.recvfrom_into(b)
                     return b[:count]
 
-                # (name, method, whether to expect success, *args)
+                # (name, method, expect success?, *args, return value func)
                 send_methods = [
-                    ('send', s.send, True, []),
-                    ('sendto', s.sendto, False, ["some.address"]),
-                    ('sendall', s.sendall, True, []),
+                    ('send', s.send, True, [], len),
+                    ('sendto', s.sendto, False, ["some.address"], len),
+                    ('sendall', s.sendall, True, [], lambda x: None),
                 ]
+                # (name, method, whether to expect success, *args)
                 recv_methods = [
                     ('recv', s.recv, True, []),
                     ('recvfrom', s.recvfrom, False, ["some.address"]),
@@ -2723,10 +2724,13 @@ if _have_threads:
                 ]
                 data_prefix = "PREFIX_"
 
-                for meth_name, send_meth, expect_success, args in send_methods:
+                for (meth_name, send_meth, expect_success, args,
+                        ret_val_meth) in send_methods:
                     indata = (data_prefix + meth_name).encode('ascii')
                     try:
-                        send_meth(indata, *args)
+                        ret = send_meth(indata, *args)
+                        msg = "sending with {}".format(meth_name)
+                        self.assertEqual(ret, ret_val_meth(indata), msg=msg)
                         outdata = s.read()
                         if outdata != indata.lower():
                             self.fail(
index cba8466109bdd1ccf4fcdc062f26d67c8e6fbbeb..f66014a7dc921382fc6076d7188baf8339c05646 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -237,6 +237,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #25951: Change SSLSocket.sendall() to return None, as explicitly
+  documented for plain socket objects.  Patch by Aviv Palivoda.
+
 - Issue #26586: In http.server, respond with "413 Request header fields too
   large" if there are too many header fields to parse, rather than killing
   the connection and raising an unhandled exception.  Patch by Xiang Zhang.