[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [tor-bugs] #8755 [Stem]: Python 3 Compatibility
#8755: Python 3 Compatibility
---------------------+------------------------------------------------------
Reporter: aj00200 | Owner: atagar
Type: defect | Status: new
Priority: normal | Milestone:
Component: Stem | Version:
Keywords: | Parent:
Points: | Actualpoints:
---------------------+------------------------------------------------------
Comment(by aj00200):
Hello,
The switch was necessary for Python 3 compatibility as Python 3 does not
have a ''decode'' method on strings.
I gave this some thought and I found a way to do that with the ''codecs''
module. Example:
{{{
>>> d = codecs.getdecoder('hex_codec')
>>> d(b'00021011ffab3a4b')
(b'\x00\x02\x10\x11\xff\xab:K', 16)
}}}
The only issue with this is that Python 3 still requires a bytes object to
be passed. This can be accomplished with the following code:
{{{
>>> d('00bb5385c0df28dc6765ac465d0cc7bc6a41ad33'.encode('ascii'))
(b'\x00\xbbS\x85\xc0\xdf(\xdcge\xacF]\x0c\xc7\xbcjA\xad3', 40)
}}}
I have tested this code with Python 2.7 and Python 3.2. If you would like
to use this solution I can code it and submit a new patch if you like. Let
me know.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/8755#comment:2>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs