Issue #16658: add missing return to HTTPConnection.send().
authorAndrew Svetlov <andrew.svetlov@gmail.com>
Fri, 12 Apr 2013 19:49:19 +0000 (22:49 +0300)
committerAndrew Svetlov <andrew.svetlov@gmail.com>
Fri, 12 Apr 2013 19:49:19 +0000 (22:49 +0300)
Patch by Jeff Knupp

Lib/http/client.py
Lib/test/test_httplib.py
Misc/NEWS

index 4663d439e32190d3527772f24ba3d3ed03f2fa0a..b72cf0891e5b67dff4e119654bfe53784c6b18c0 100644 (file)
@@ -866,7 +866,7 @@ class HTTPConnection:
                 if encode:
                     datablock = datablock.encode("iso-8859-1")
                 self.sock.sendall(datablock)
-
+            return
         try:
             self.sock.sendall(data)
         except TypeError:
index db123dcb56f7b4a4dd83f47a7735d48a9b51d0e1..863e4bc22bc6b42dbf86580c687826cf0b74724a 100644 (file)
@@ -371,6 +371,27 @@ class BasicTest(TestCase):
         conn.send(io.BytesIO(expected))
         self.assertEqual(expected, sock.data)
 
+    def test_send_updating_file(self):
+        def data():
+            yield 'data'
+            yield None
+            yield 'data_two'
+
+        class UpdatingFile():
+            mode = 'r'
+            d = data()
+            def read(self, blocksize=-1):
+                return self.d.__next__()
+
+        expected = b'data'
+
+        conn = client.HTTPConnection('example.com')
+        sock = FakeSocket("")
+        conn.sock = sock
+        conn.send(UpdatingFile())
+        self.assertEqual(sock.data, expected)
+
+
     def test_send_iter(self):
         expected = b'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \
                    b'Accept-Encoding: identity\r\nContent-Length: 11\r\n' \
index 2adfb5eba88f3130b9f0f86b409c4c109329c524..c8acda3d601e60f0e804980562222b2d002d69ba 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -23,6 +23,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #16658: add missing return to HTTPConnection.send()
+  Patch by Jeff Knupp.
+
 - Issue #14971: unittest test discovery no longer gets confused when a function
   has a different __name__ than its name in the TestCase class dictionary.