From 0076baee81a9510aa1d646d3439d7e0ded4d9ad8 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 2 Apr 2016 02:29:24 -0400 Subject: [PATCH] apply lawnmowerwcd's python binding fix for converting python list to std::vector --- bindings/python/src/torrent_handle.cpp | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/bindings/python/src/torrent_handle.cpp b/bindings/python/src/torrent_handle.cpp index 6b608dda5..1352a6b74 100644 --- a/bindings/python/src/torrent_handle.cpp +++ b/bindings/python/src/torrent_handle.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -163,25 +164,9 @@ void prioritize_pieces(torrent_handle& info, object o) void prioritize_files(torrent_handle& info, object o) { std::vector result; - try - { - object iter_obj = object( handle<>( PyObject_GetIter( o.ptr() ) )); - while( 1 ) - { -#if PY_MAJOR_VERSION >= 3 - object obj = extract( iter_obj.attr( "__next__" )() ); -#else - object obj = extract( iter_obj.attr( "next" )() ); -#endif - result.push_back(extract( obj )); - } - } - catch( error_already_set ) - { - PyErr_Clear(); - info.prioritize_files(result); - return; - } + stl_input_iterator begin(o), end; + result.insert(result.begin(), begin, end); + info.prioritize_files(result); } list file_priorities(torrent_handle& handle)