From 1e991f2de5d705155e430400c8cbc24071e3df72 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Fri, 24 Dec 2010 04:03:59 +0000 Subject: Fix some mistakes- Issue3243 (r87399) Correcting the operator precendence problem with Content-Length header and uncommenting the test. --- Lib/http/client.py | 2 +- Lib/test/test_urllib2.py | 2 -- Lib/urllib/request.py | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/http/client.py b/Lib/http/client.py index 8d62aa5..bb9fa9b 100644 --- a/Lib/http/client.py +++ b/Lib/http/client.py @@ -775,7 +775,7 @@ class HTTPConnection: for d in data: self.sock.sendall(d) else: - raise TypeError("data should be byte-like object\ + raise TypeError("data should be a bytes-like object\ or an iterable, got %r " % type(it)) def _output(self, s): diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index 1ce88af..b8a609e 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -839,7 +839,6 @@ class HandlerTests(unittest.TestCase): # A file object - """ file_obj = io.StringIO() file_obj.write("Something\nSomething\nSomething\n") @@ -863,7 +862,6 @@ class HandlerTests(unittest.TestCase): req = Request("http://example.com/", iterable_array, headers) newreq = h.do_request_(req) self.assertEqual(int(newreq.get_header('Content-length')),16) - """ def test_http_doubleslash(self): diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index a88bc99..4436105 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1062,7 +1062,7 @@ class AbstractHTTPHandler(BaseHandler): data)) else: request.add_unredirected_header( - 'Content-length', '%d' % len(mv) * mv.itemsize) + 'Content-length', '%d' % (len(mv) * mv.itemsize)) sel_host = host if request.has_proxy(): -- cgit v0.12