socks.py throws "bad, input" exception when destpair[0] value is unicode
Closed this issue · 3 comments
GoogleCodeExporter commented
In socks.py line 359
def connect(self, destpair):
"""connect(self, despair)
Connects to the specified destination through a proxy.
destpar - A tuple of the IP/DNS address and the port number.
(identical to socket's connect).
To select the proxy server use setproxy().
"""
# Do a minimal input check first
#if (not type(destpair) in (list,tuple)) or (len(destpair) < 2) or (type(destpair[0]) != type('')) or (type(destpair[1]) != int):
#raise GeneralProxyError((5, _generalerrors[5]))
Sometimes destpair[0] is Unicode and the condition type(destpair[0]) != type(''
fails miserably.
One solution is to replace the check with the following (see
http://nedbatchelder.com/blog/201003/criminal_exceptions.html)
if not isinstance(destpair, (list, tuple)) and len(destpair) != 2 and not isinstance(destpair[0], basestring) and not isinstance(despair[1], int):
raise GeneralProxyError((5, _generalerrors[5] + '\ndestpair myst be a list or tuple of length two with the first being a string and the second being and int\n destpair = %r' % (destpair,)))
Cheers
Original issue reported on code.google.com by paul.ama...@gmail.com
on 27 Sep 2011 at 1:33
GoogleCodeExporter commented
Fix available in
https://bitbucket.org/jaraco/httplib2/changesets/tip/branch%28%22issue%20179%22%
29 .
Original comment by jar...@jaraco.com
on 1 Dec 2011 at 9:16
GoogleCodeExporter commented
Fixed in
http://code.google.com/p/httplib2/source/detail?r=9ae3ddb265d4ec127e5458e1176420
542ccf63ab
Thanks for the fix!
Original comment by joe.gregorio@gmail.com
on 6 Jan 2012 at 2:38
- Changed state: Fixed
GoogleCodeExporter commented
Hangs forever when I try to click on the fix link.
Original comment by bbrock...@gmail.com
on 29 Apr 2015 at 9:47