Hi, I have exported an array-like class using the __getitem__ implementation given below among its overloads. It uses boost::python::slice.get_indices(), and I am getting a RuntimeError when I try to acces e.g. [1:-1] on a 2-element array. What is the rationale for this "Zero-length slice" error? I would expect an empty iterator range. OK, if end < begin, that could make problems, but what am I expected to do to prevent this RuntimeError? (Yes, I did RTFM, but maybe I am overlooking something?)
template<class Array>
std::auto_ptr<Array>
Array__getitem_slice__(Array const & a, boost::python::slice sl)
{
boost::python::slice::range<typename Array::const_iterator>
bounds = sl.template get_indicies<>(a.begin(), a.end());
if(bounds.step != 1)
{
PyErr_SetString(PyExc_IndexError,
"No extended slicing supported yet.");
boost::python::throw_error_already_set();
}
return std::auto_ptr<Array>(new Array(bounds.start, bounds.stop+1));
}
Ciao, / / .o.
/--/ ..o
/ / ANS ooo
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Cplusplus-sig mailing list [email protected] http://mail.python.org/mailman/listinfo/cplusplus-sig
