From: Senthil Kumaran Date: Tue, 2 Aug 2011 10:33:41 +0000 (+0800) Subject: Fix closes Issue12676 - Invalid identifier used in TypeError message in http.client. X-Git-Tag: v3.2.2rc1~35 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb71ad4c71a95d9b7397e3baaaadcb0687efa894;p=python Fix closes Issue12676 - Invalid identifier used in TypeError message in http.client. Reported by Popa Claudiu and Patch by Santoso Wijaya. --- diff --git a/Lib/http/client.py b/Lib/http/client.py index 604577cd7b..4906007972 100644 --- a/Lib/http/client.py +++ b/Lib/http/client.py @@ -778,7 +778,7 @@ class HTTPConnection: self.sock.sendall(d) else: raise TypeError("data should be a bytes-like object\ - or an iterable, got %r " % type(it)) + or an iterable, got %r " % type(data)) def _output(self, s): """Add a line of output to the current request buffer. diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index 890b1b9028..ce9e34638a 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -246,6 +246,13 @@ class BasicTest(TestCase): conn.request('GET', '/foo', body(), {'Content-Length': '11'}) self.assertEqual(sock.data, expected) + def test_send_type_error(self): + # See: Issue #12676 + conn = client.HTTPConnection('example.com') + conn.sock = FakeSocket('') + with self.assertRaises(TypeError): + conn.request('POST', 'test', conn) + def test_chunked(self): chunked_start = ( 'HTTP/1.1 200 OK\r\n'