forked from LBRYCommunity/lbry-sdk
port dht.encoding ~> py3
This commit is contained in:
parent
78c560a3be
commit
9967857a57
1 changed files with 4 additions and 3 deletions
|
@ -1,6 +1,8 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from .error import DecodeError
|
from .error import DecodeError
|
||||||
|
import sys
|
||||||
|
if sys.version_info > (3,):
|
||||||
|
long = int
|
||||||
|
|
||||||
class Encoding(object):
|
class Encoding(object):
|
||||||
""" Interface for RPC message encoders/decoders
|
""" Interface for RPC message encoders/decoders
|
||||||
|
@ -63,8 +65,7 @@ class Bencode(Encoding):
|
||||||
elif isinstance(data, dict):
|
elif isinstance(data, dict):
|
||||||
encodedDictItems = ''
|
encodedDictItems = ''
|
||||||
keys = data.keys()
|
keys = data.keys()
|
||||||
keys.sort()
|
for key in sorted(keys):
|
||||||
for key in keys:
|
|
||||||
encodedDictItems += self.encode(key) # TODO: keys should always be bytestrings
|
encodedDictItems += self.encode(key) # TODO: keys should always be bytestrings
|
||||||
encodedDictItems += self.encode(data[key])
|
encodedDictItems += self.encode(data[key])
|
||||||
return 'd%se' % encodedDictItems
|
return 'd%se' % encodedDictItems
|
||||||
|
|
Loading…
Reference in a new issue