diff --git a/bindings/python/src/alert.cpp b/bindings/python/src/alert.cpp index 1d15c5569..7a3f3223d 100644 --- a/bindings/python/src/alert.cpp +++ b/bindings/python/src/alert.cpp @@ -8,14 +8,15 @@ #include // for piece_block #include #include +#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_, 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_, noncopyable>( diff --git a/bindings/python/test.py b/bindings/python/test.py index bc7f60659..9b6669fdf 100644 --- a/bindings/python/test.py +++ b/bindings/python/test.py @@ -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()