[Python-checkins] cpython (merge 3.3 -> default): Issue #16658: add missing return to HTTPConnection.send().

andrew.svetlov python-checkins at python.org
Fri Apr 12 21:51:09 CEST 2013


http://hg.python.org/cpython/rev/2b89e9a6b482
changeset:   83276:2b89e9a6b482
parent:      83274:e68bd20b5434
parent:      83275:70c7687de1cd
user:        Andrew Svetlov <andrew.svetlov at gmail.com>
date:        Fri Apr 12 22:50:42 2013 +0300
summary:
  Issue #16658: add missing return to HTTPConnection.send().

Patch by Jeff Knupp

files:
  Lib/http/client.py       |   2 +-
  Lib/test/test_httplib.py |  21 +++++++++++++++++++++
  Misc/NEWS                |   3 +++
  3 files changed, 25 insertions(+), 1 deletions(-)


diff --git a/Lib/http/client.py b/Lib/http/client.py
--- a/Lib/http/client.py
+++ b/Lib/http/client.py
@@ -864,7 +864,7 @@
                 if encode:
                     datablock = datablock.encode("iso-8859-1")
                 self.sock.sendall(datablock)
-
+            return
         try:
             self.sock.sendall(data)
         except TypeError:
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -373,6 +373,27 @@
         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' \
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -34,6 +34,9 @@
 Library
 -------
 
+- Issue #16658: add missing return to HTTPConnection.send()
+  Patch by Jeff Knupp.
+
 - Issue #9556: Allowed specifying a time-of-day for a TimedRotatingFileHandler
   to rotate.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list