pythonpython-3.xtorpycurlstem

Tor API example not works correct


I'm trying to run example named "Using PycURL" from here https://stem.torproject.org/tutorials/to_russia_with_love.html

Everything works fine, but in the final i have this some kind of error:

TypeError : String argument expected, got 'bytes'
Unable to reach http://google.com <<23, 'Failed writing body <0 != 144>'>>

The question is, how can i fix these?

I've tried to use PyCurl as is without any proxy and it works fine. But this example not works.

I'm running Python 3.4 under Windows, here is my source code http://pastebin.com/zFWrXU5E

Tnanks.

P.S. I need this to work exactly with PyCurl, cuz it is most usefull for my tasks.

P.S. #2 : I did little crutch, seems like it work http://pastebin.com/x8PtL9i3 Heh.

P.S. #3 : Hey! I get the error point, it's in the WRITEFUNCTION of PyCurl, somehow io.StringIO().write function not works ...


Solution

  • Solved.

    Problem was in Python 3.4, cuz StringIO object was changed. All you need is to change output var type from StringIO to BytesIO and then convert bytes to string for printing result.

    Here is working source code : http://pastebin.com/Ad8ENTGe

    Thanks.


    P.S. Who placed -1 ??? haters...