title: SocksiPy fails when connecting throug Tor
body: <p>Tried the 3 following methods to control Tor:</p>
  
  <ul>
  <li>using TorCtl/urllib2: <a href="https://stackoverflow.com/questions/9925381/python-script-exception-with-tor?rq=1">Python script Exception with Tor</a></li>
  <li>using socks/httplib: <a href="http://www.youtube.com/watch?v=KDsmVH7eJCs" rel="nofollow noreferrer">http://www.youtube.com/watch?v=KDsmVH7eJCs</a></li>
  <li>using socks/urllib2: <a href="https://stackoverflow.com/questions/5148589/python-urllib-over-tor">Python urllib over TOR?</a></li>
  </ul>
  
  <p>Each of them fails w/ same error (tried to make it as clear as possible):</p>
  
  <pre><code>Traceback (most recent call last):
  
  File "tor.py", line 26, in &lt;module&gt;
    print(urllib2.urlopen("http://www.ifconfig.me/ip").read())
  
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py"
  line 127, in urlopen
    return _opener.open(url, data, timeout)
  line 404, in open
    response = self._open(req, data)
  line 422, in _open
    '_open', req)
  line 382, in _call_chain
    result = func(*args)
  line 1214, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  line 1181, in do_open
    h.request(req.get_method(), req.get_selector(), req.data, headers)
  
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py"
  line 973, in request
    self._send_request(method, url, body, headers)
  line 1007, in _send_request
    self.endheaders(body)
  line 969, in endheaders
    self._send_output(message_body)
  line 829, in _send_output
    self.send(msg)
  line 791, in send
    self.connect()
  line 772, in connect
    self.timeout, self.source_address)
  
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py"
  line 562, in create_connection
    sock.connect(sa)
  
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/SocksiPy_branch-1.01-py2.7.egg/socks.py"
  line 392, in connect
    self.__negotiatesocks5(destpair[0],destpair[1])
  line 199, in __negotiatesocks5
    self.sendall("\x05\x01\x00")
  line 165, in sendall
    socket.socket.sendall(self, bytes)
  </code></pre>
  
  <p><strong>... last error repeating a lot of times and then ...</strong></p>
  
  <pre><code>File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/SocksiPy_branch-1.01-py2.7.egg/socks.py", line 163, in sendall
    if 'encode' in dir(bytes):
  RuntimeError: maximum recursion depth exceeded while calling a Python object
  </code></pre>
  
  <p>Does anyone understand where it comes from?</p>