fix bindings for python3 (#994)

fix bindings for python3
This commit is contained in:
Arvid Norberg 2016-08-10 07:26:02 -04:00 committed by GitHub
parent 231dffd392
commit 330e683d13
2 changed files with 7 additions and 4 deletions

View File

@ -51,7 +51,7 @@ struct entry_to_python
list l;
for (std::vector<char>::const_iterator i = pre.begin()
, end(pre.end()); i != end; ++i)
l.append(*i);
l.append(int(*i));
return tuple(l);
}
default:
@ -153,7 +153,7 @@ struct entry_from_python
std::vector<char> preformatted(length);
for (std::size_t i = 0; i < length; ++i)
{
preformatted[i] = extract<char>(t[i]);
preformatted[i] = char(extract<int>(t[i]));
}
return entry(preformatted);

View File

@ -16,8 +16,11 @@ class test_create_torrent(unittest.TestCase):
ct = lt.create_torrent(ti)
entry = ct.generate()
content = lt.bencode(entry).strip()
with open('unordered.torrent', 'r') as f:
file_content = f.read().strip()
with open('unordered.torrent', 'rb') as f:
file_content = bytearray(f.read().strip())
print(content)
print(file_content)
print(entry)
self.assertEqual(content, file_content)
class test_torrent_handle(unittest.TestCase):