changeset: 83275:70c7687de1cd branch: 3.3 parent: 83272:26639365e62b user: Andrew Svetlov date: Fri Apr 12 22:49:19 2013 +0300 files: Lib/http/client.py Lib/test/test_httplib.py Misc/NEWS description: Issue #16658: add missing return to HTTPConnection.send(). Patch by Jeff Knupp diff -r 26639365e62b -r 70c7687de1cd Lib/http/client.py --- a/Lib/http/client.py Fri Apr 12 19:19:21 2013 +0300 +++ b/Lib/http/client.py Fri Apr 12 22:49:19 2013 +0300 @@ -866,7 +866,7 @@ if encode: datablock = datablock.encode("iso-8859-1") self.sock.sendall(datablock) - + return try: self.sock.sendall(data) except TypeError: diff -r 26639365e62b -r 70c7687de1cd Lib/test/test_httplib.py --- a/Lib/test/test_httplib.py Fri Apr 12 19:19:21 2013 +0300 +++ b/Lib/test/test_httplib.py Fri Apr 12 22:49:19 2013 +0300 @@ -371,6 +371,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 -r 26639365e62b -r 70c7687de1cd Misc/NEWS --- a/Misc/NEWS Fri Apr 12 19:19:21 2013 +0300 +++ b/Misc/NEWS Fri Apr 12 22:49:19 2013 +0300 @@ -23,6 +23,9 @@ 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.