fix python3 binding for read_piece::buffer

This commit is contained in:
arvidn 2016-04-01 17:55:15 -04:00
parent e3db774828
commit 296c6c24c4
2 changed files with 7 additions and 7 deletions

View File

@ -8,14 +8,15 @@
#include <libtorrent/piece_picker.hpp> // for piece_block
#include <libtorrent/session_stats.hpp>
#include <memory>
#include "bytes.hpp"
using namespace boost::python;
using namespace libtorrent;
std::string get_buffer(read_piece_alert const& rpa)
bytes get_buffer(read_piece_alert const& rpa)
{
return rpa.buffer ? std::string(rpa.buffer.get(), rpa.size)
: std::string();
return rpa.buffer ? bytes(rpa.buffer.get(), rpa.size)
: bytes();
}
tuple endpoint_to_tuple(tcp::endpoint const& ep)
@ -267,7 +268,7 @@ void bind_alert()
class_<torrent_removed_alert, bases<torrent_alert>, noncopyable>(
"torrent_removed_alert", no_init)
.def_readonly("info_hash", &torrent_removed_alert::info_hash)
.def_readonly("info_hash", &torrent_removed_alert::info_hash)
;
class_<read_piece_alert, bases<torrent_alert>, noncopyable>(

View File

@ -12,7 +12,6 @@ class test_torrent_handle(unittest.TestCase):
def test_torrent_handle(self):
ses = lt.session({'alert_mask': lt.alert.category_t.all_categories})
shutil.copy(os.path.join('..', '..', 'test', 'test_torrents', 'url_seed_multi.torrent'), '.')
ti = lt.torrent_info('url_seed_multi.torrent');
h = ses.add_torrent({'ti': ti, 'save_path': os.getcwd()})
@ -37,7 +36,6 @@ class test_torrent_info(unittest.TestCase):
self.assertEqual(info.total_size(), 1234)
def test_metadata(self):
shutil.copy(os.path.join('..', '..', 'test', 'test_torrents', 'base.torrent'), '.')
ti = lt.torrent_info('base.torrent');
self.assertTrue(len(ti.metadata()) != 0)
@ -48,7 +46,6 @@ class test_alerts(unittest.TestCase):
def test_alert(self):
ses = lt.session({'alert_mask': lt.alert.category_t.all_categories})
shutil.copy(os.path.join('..', '..', 'test', 'test_torrents', 'base.torrent'), '.')
ti = lt.torrent_info('base.torrent');
h = ses.add_torrent({'ti': ti, 'save_path': os.getcwd()})
st = h.status()
@ -106,5 +103,7 @@ class test_session(unittest.TestCase):
if __name__ == '__main__':
print(lt.__version__)
shutil.copy(os.path.join('..', '..', 'test', 'test_torrents', 'url_seed_multi.torrent'), '.')
shutil.copy(os.path.join('..', '..', 'test', 'test_torrents', 'base.torrent'), '.')
unittest.main()