From a0c31b47e5c1a67db18deb32cc5e47282f212686 Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Sun, 10 Aug 2003 15:20:10 +0000 Subject: [PATCH] refactored code + cleanup [SVN r19508] --- .../boost/python/indexing/indexing_suite.hpp | 32 ++----------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/include/boost/python/indexing/indexing_suite.hpp b/include/boost/python/indexing/indexing_suite.hpp index 531b2f60..6ec7240e 100644 --- a/include/boost/python/indexing/indexing_suite.hpp +++ b/include/boost/python/indexing/indexing_suite.hpp @@ -10,6 +10,7 @@ # include # include # include +# include # include # include # include @@ -303,37 +304,10 @@ namespace boost { namespace python { static void base_extend(Container& container, PyObject* v) { - // v must be a list or some container + std::vector temp; handle<> l_(borrowed(v)); object l(l_); - - std::vector temp; - for (int i = 0; i < l.attr("__len__")(); i++) - { - object elem(l[i]); - extract x(elem); - // try if elem is an exact Element type - if (x.check()) - { - temp.push_back(x()); - } - else - { - // try to convert elem to Element type - extract x(elem); - if (x.check()) - { - temp.push_back(x()); - } - else - { - PyErr_SetString(PyExc_TypeError, - "Invalid list element"); - throw_error_already_set(); - } - } - } - + container_utils::extend_container(temp, l); DerivedPolicies::extend(container, temp.begin(), temp.end()); } };