Menu

#34 Indexing Suite V2 throws wrong exception for std::map

open
nobody
None
5
2011-10-13
2011-10-13
No

The Indexing Suite V2's boost::python::indexing::map_suite class throws a ValueError exception when the wrapped std::map instance's __getitem__ method is called with a key value that the std::map doesn't contain.
Since a Python dict object's __getitem__ method throws a KeyError exception when it's called with a key value that it doesn't contain, the boost::python::indexing::map_suite class' implementation of __getitem__ should throw a KeyError exception as well.

The error is on line 499 of indexing_suite/algorithms.hpp:

template<typename ContainerTraits, typename Ovr>
BOOST_DEDUCED_TYPENAME assoc_algorithms<ContainerTraits, Ovr>::iterator
assoc_algorithms<ContainerTraits, Ovr>::find_or_throw(
container &c, index_param ix)
{
iterator iter = most_derived::find (c, ix);

if (iter == most_derived::end(c))
{
PyErr_SetString(
PyExc_ValueError, "associative container: key not found");
^

This bug was found in revision 1856.

Discussion


Log in to post a comment.