Merge pull request #378 from aresch/py3

Fix python 3 compatibility
This commit is contained in:
Arvid Norberg 2016-01-11 08:24:06 -05:00
commit c7e19ce667
2 changed files with 6 additions and 5 deletions

View File

@ -100,7 +100,7 @@ namespace
void make_settings_pack(lt::settings_pack& p, dict const& sett_dict)
{
list iterkeys = (list)sett_dict.iterkeys();
list iterkeys = (list)sett_dict.keys();
for (int i = 0; i < boost::python::len(iterkeys); i++)
{
std::string key = extract<std::string>(iterkeys[i]);
@ -583,6 +583,7 @@ namespace
void bind_session()
{
register_ptr_to_python<boost::shared_ptr<alert> >();
#ifndef TORRENT_DISABLE_DHT
void (lt::session::*dht_get_immutable_item)(sha1_hash const&) = &lt::session::dht_get_item;
sha1_hash (lt::session::*dht_put_immutable_item)(entry data) = &lt::session::dht_put_item;

View File

@ -57,13 +57,13 @@ class test_bencoder(unittest.TestCase):
def test_bencode(self):
encoded = lt.bencode({'a': 1, 'b': [1,2,3], 'c': 'foo'})
self.assertEqual(encoded, 'd1:ai1e1:bli1ei2ei3ee1:c3:fooe')
self.assertEqual(encoded, b'd1:ai1e1:bli1ei2ei3ee1:c3:fooe')
def test_bdecode(self):
encoded = 'd1:ai1e1:bli1ei2ei3ee1:c3:fooe'
encoded = b'd1:ai1e1:bli1ei2ei3ee1:c3:fooe'
decoded = lt.bdecode(encoded)
self.assertEqual(decoded, {'a': 1, 'b': [1,2,3], 'c': 'foo'})
self.assertEqual(decoded, {b'a': 1, b'b': [1,2,3], b'c': b'foo'})
class test_sha1hash(unittest.TestCase):
@ -74,6 +74,6 @@ class test_sha1hash(unittest.TestCase):
if __name__ == '__main__':
print lt.__version__
print(lt.__version__)
unittest.main()