Title: Open url with proxy causes TypeError
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
Status: closed Resolution: duplicate
Dependencies: Superseder: Missing size argument in readline() method for httplib's class LineAndFileWrapper
View: 17849
Assigned To: Nosy List: orsenthil, r.david.murray, zhang.kai
Priority: normal Keywords:

Created on 2012-09-12 05:44 by zhang.kai, last changed 2015-05-31 03:32 by martin.panter. This issue is now closed.

Messages (4)
msg170354 - (view) Author: zhang kai (zhang.kai) Date: 2012-09-12 05:44
Here is the code which causes this bug:
 proxy_handler = urllib2.ProxyHandler({'https': proxy})
 opener = urllib2.build_opener(proxy_handler)
 f ='?'+params)

Here are the traceback information:
Traceback (most recent call last):
  File "", line 65, in <module>
  File "", line 62, in main
    print proxy_manager.get_proxy()
  File "", line 45, in get_proxy
    make_request(TEST_URL, proxy=one["proxy_server"])
  File "", line 27, in make_request
    f ='?'+params)
  File "/usr/lib/python2.7/", line 400, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/", line 418, in _open
    '_open', req)
  File "/usr/lib/python2.7/", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/", line 1215, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "/usr/lib/python2.7/", line 1174, in do_open
    h.request(req.get_method(), req.get_selector(),, headers)
  File "/usr/lib/python2.7/", line 958, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/", line 992, in _send_request
  File "/usr/lib/python2.7/", line 954, in endheaders
  File "/usr/lib/python2.7/", line 814, in _send_output
  File "/usr/lib/python2.7/", line 776, in send
  File "/usr/lib/python2.7/", line 1160, in connect
  File "/usr/lib/python2.7/", line 748, in _tunnel
    line = response.fp.readline(_MAXLINE + 1)
TypeError: readline() takes exactly 1 argument (2 given)
msg170355 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2012-09-12 06:13
Have a look at the ProxyHandler example in the Examples here -
Also, construct the full url properly with urlencoded data as params.

Your report does not give any details of problem.
msg170356 - (view) Author: zhang kai (zhang.kai) Date: 2012-09-12 06:24
Well, I do have encoded the params, that is not the problem.
Also these code did work for most of the time, I don't know why this bug happen so I don't know any details about the problem. Sorry about that.
msg170362 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-09-12 10:15
What is proxy?  Perhaps it does not implement readline correctly.
Date User Action Args
2015-05-31 03:32:17martin.pantersetsuperseder: Missing size argument in readline() method for httplib's class LineAndFileWrapper
resolution: not a bug -> duplicate
2012-09-12 10:15:23r.david.murraysetnosy: + r.david.murray
messages: + msg170362
2012-09-12 06:24:57zhang.kaisetmessages: + msg170356
2012-09-12 06:14:11orsenthilsetstatus: open -> closed
2012-09-12 06:13:39orsenthilsetnosy: + orsenthil
messages: + msg170355

resolution: not a bug
stage: resolved
2012-09-12 05:44:41zhang.kaicreate