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)