Menu

#4 TypeError in Python 3.1

open
nobody
None
5
2009-07-13
2009-07-13
Motoma
No

"TypeError: sendall() argument 1 must be bytes or buffer, not str"
Occurs in Python 3.1 on Windows Vista.
Happens when trying to connection via SOCKS5 to Vidalia.

Discussion

  • Mario Vilas

    Mario Vilas - 2010-05-18

    I don't think this module is supposed to be compatible with python 3 in the first place...

     
  • Motoma

    Motoma - 2010-05-18

    It could be, by simply adding a .encode() call before issuing a sends.

     
  • Mario Vilas

    Mario Vilas - 2010-05-18

    Wouldn't that break compatibility with python 2? (I'm not all that familiar with python 3 yet)

     
  • Motoma

    Motoma - 2010-05-18

    Not necessarily.
    If you look at my source tree for PyLoris, I made a few minor modifications to this library in order to support both Python 2.x and 3.x: http://pyloris.svn.sourceforge.net/viewvc/pyloris/tags/pyloris-2.3/socks.py?revision=60&view=markup

    There are a few ways to do this: writing a version dependent formatting function (which I did), modifying the socksocket sendall member function in a version dependent way at load time, or have a version conditional branch at execution time.

     
  • Mario Vilas

    Mario Vilas - 2010-05-19

    Interesting! Do you mind if I merge your fix here? http://code.google.com/p/socksipy-branch

     
  • Motoma

    Motoma - 2010-05-19

    Certainly. It's great to see that someone has taken over this project. I tried contacting Dan Haim last year offering to do just that, but I received no response and just made the modifications to my own code base.

    I think it's worth mentioning, bytes will probably need to be called in struct.unpack in __negotioatesocks4 as well.

     

Log in to post a comment.

MongoDB Logo MongoDB