Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eb71ad4

Browse files
committed
Fix closes Issue12676 - Invalid identifier used in TypeError message in http.client.
Reported by Popa Claudiu and Patch by Santoso Wijaya.
1 parent f187a02 commit eb71ad4

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

Lib/http/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ def send(self, data):
778778
self.sock.sendall(d)
779779
else:
780780
raise TypeError("data should be a bytes-like object\
781-
or an iterable, got %r " % type(it))
781+
or an iterable, got %r " % type(data))
782782

783783
def _output(self, s):
784784
"""Add a line of output to the current request buffer.

Lib/test/test_httplib.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,13 @@ def body():
246246
conn.request('GET', '/foo', body(), {'Content-Length': '11'})
247247
self.assertEqual(sock.data, expected)
248248

249+
def test_send_type_error(self):
250+
# See: Issue #12676
251+
conn = client.HTTPConnection('example.com')
252+
conn.sock = FakeSocket('')
253+
with self.assertRaises(TypeError):
254+
conn.request('POST', 'test', conn)
255+
249256
def test_chunked(self):
250257
chunked_start = (
251258
'HTTP/1.1 200 OK\r\n'

0 commit comments

Comments
 (0)