From 9967857a57ed71deab02fe50362ed33e81cdea7e Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Tue, 17 Jul 2018 21:38:54 -0300 Subject: [PATCH] port dht.encoding ~> py3 --- lbrynet/dht/encoding.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lbrynet/dht/encoding.py b/lbrynet/dht/encoding.py index f246ed747..43dc64fd4 100644 --- a/lbrynet/dht/encoding.py +++ b/lbrynet/dht/encoding.py @@ -1,6 +1,8 @@ from __future__ import print_function from .error import DecodeError - +import sys +if sys.version_info > (3,): + long = int class Encoding(object): """ Interface for RPC message encoders/decoders @@ -63,8 +65,7 @@ class Bencode(Encoding): elif isinstance(data, dict): encodedDictItems = '' keys = data.keys() - keys.sort() - for key in keys: + for key in sorted(keys): encodedDictItems += self.encode(key) # TODO: keys should always be bytestrings encodedDictItems += self.encode(data[key]) return 'd%se' % encodedDictItems