Python SocksiPy package error: TypeError: Type str doesn't support the buffer API for string?
Question: When i try and connect to gmail through this code:

    
    
    import socks
    import imaplib
    import socket
    import socks
    s = socks.socksocket()
    s.setproxy(socks.PROXY_TYPE_HTTP, '192.168.208.51', 3128)
    s.connect(('imap.gmail.com', 993))
    

I get the error message:

    
    
    Traceback (most recent call last):
    File "<pyshell#18>", line 1, in <module>
    s.connect(('imap.gmail.com', 993))
    File "C:\Python34\lib\site-packages\socks.py", line 406, in connect
    self.__negotiatehttp(destpair[0],destpair[1])
    File "C:\Python34\lib\site-packages\socks.py", line 357, in __negotiatehttp
    while resp.find("\r\n\r\n")==-1:
    TypeError: Type str doesn't support the buffer API
    

Any ideas? Im on a computer that uses a proxy hence using SocksiPy to connect
to imap.gmail.com


Answer: There's nothing wrong with your code; you are using a version of SocksiPy that
has not been ported to Python 3. You should upgrade to version 1.02. Or you
should switch back to Python 2.

* * *

**Explaination:**

This is Python 3. Unlike Python 2, `bytes` and `str` objects are not
interchangeable. If you try to do stuff like this:

    
    
    >>> b'abc'.find('a')
    

You'll get the error you are seeing. In fact, the "buffer API" is the one
implemented by `bytes` objects.

