]> granicus.if.org Git - python/commitdiff
Fix closes Issue12676 - Invalid identifier used in TypeError message in http.client.
authorSenthil Kumaran <senthil@uthcode.com>
Tue, 2 Aug 2011 10:33:41 +0000 (18:33 +0800)
committerSenthil Kumaran <senthil@uthcode.com>
Tue, 2 Aug 2011 10:33:41 +0000 (18:33 +0800)
Reported by Popa Claudiu and Patch by Santoso Wijaya.

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

index 604577cd7b2e28b7976406f086c2b68aa3c630c9..490600797292c98df8776f39eb7668c661761c90 100644 (file)
@@ -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.
index 890b1b9028ccf70118e06a8b073bb24027b5c084..ce9e34638acbbc89218fe99e916e4f3c174ea5ee 100644 (file)
@@ -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'