[C++-sig] length of boost.python error messages

John Reid j.reid at mail.cryst.bbk.ac.uk
Fri Apr 13 18:34:33 CEST 2007


Hi,

When developing or using boost.python modules I frequently get Python 
argument type mismatches. Boost.python tells me that the arguments I 
have passed do not match/cannot be converted to the expected types. 
Unfortunately normally these C++ types are templates and are almost 
impossible to decipher from the error message.

Perhaps it would be possible to place a newline in between the type of 
each argument that was passed and also in between the type of each 
argument that was expected. This could improve the readability of the 
error messages. A more general scheme for pretty printing templated 
types would be nice but I'm sure would be a lot more work.

For example recently I found it difficult to determine which argument 
was incorrect from this error message:

Traceback (most recent call last):
   File "temp.py", line 12, in <module>
     distance_map = distances
Boost.Python.ArgumentError: Python argument types in
     boost.graph._graph.dijkstra_shortest_paths(Graph, Vertex)
did not match C++ signature:
     dijkstra_shortest_paths(class 
boost::graph::python::basic_graph<struct boost
::bidirectionalS> graph, struct 
boost::graph::python::basic_descriptor<void *,st
ruct boost::bidirectionalS> root_vertex, class 
boost::vector_property_map<struct
  boost::graph::python::basic_descriptor<void *,struct 
boost::bidirectionalS>,str
uct boost::graph::python::basic_index_map<struct 
boost::graph::python::basic_des
criptor<void *,struct boost::bidirectionalS>,struct 
boost::adj_list_vertex_prope
rty_map<class boost::adjacency_list<struct boost::listS,struct 
boost::listS,stru
ct boost::bidirectionalS,struct boost::property<enum 
boost::vertex_index_t,unsig
ned int,struct boost::no_property>,struct boost::property<enum 
boost::edge_index
_t,unsigned int,struct boost::no_property>,struct 
boost::no_property,struct boos
t::listS>,unsigned int,unsigned int const &,enum boost::vertex_index_t> 
 > > * pr
edecessor_map=None, class boost::vector_property_map<float,struct 
boost::graph::
python::basic_index_map<struct 
boost::graph::python::basic_descriptor<void *,str
uct boost::bidirectionalS>,struct 
boost::adj_list_vertex_property_map<class boos
t::adjacency_list<struct boost::listS,struct boost::listS,struct 
boost::bidirect
ionalS,struct boost::property<enum boost::vertex_index_t,unsigned 
int,struct boo
st::no_property>,struct boost::property<enum 
boost::edge_index_t,unsigned int,st
ruct boost::no_property>,struct boost::no_property,struct 
boost::listS>,unsigned
  int,unsigned int const &,enum boost::vertex_index_t> > > * 
distance_map=None, c
lass boost::vector_property_map<float,struct 
boost::graph::python::basic_index_m
ap<struct boost::graph::python::basic_descriptor<class 
boost::detail::edge_desc_
impl<struct boost::bidirectional_tag,void *>,struct 
boost::bidirectionalS>,struc
t boost::adj_list_edge_property_map<struct 
boost::bidirectional_tag,unsigned int
,unsigned int const &,void *,struct boost::property<enum 
boost::edge_index_t,uns
igned int,struct boost::no_property> const ,enum boost::edge_index_t> > 
 > {lvalu
e} weight_map, class boost::python::api::object visitor=None, class 
boost::vecto
r_property_map<enum boost::default_color_type,struct 
boost::graph::python::basic
_index_map<struct boost::graph::python::basic_descriptor<void *,struct 
boost::bi
directionalS>,struct boost::adj_list_vertex_property_map<class 
boost::adjacency_
list<struct boost::listS,struct boost::listS,struct 
boost::bidirectionalS,struct
  boost::property<enum boost::vertex_index_t,unsigned int,struct 
boost::no_proper
ty>,struct boost::property<enum boost::edge_index_t,unsigned int,struct 
boost::n
o_property>,struct boost::no_property,struct boost::listS>,unsigned 
int,unsigned
  int const &,enum boost::vertex_index_t> > > * color_map=None)
     dijkstra_shortest_paths(class 
boost::graph::python::basic_graph<struct boost
::undirectedS> graph, struct boost::graph::python::basic_descriptor<void 
*,struc
t boost::undirectedS> root_vertex, class 
boost::vector_property_map<struct boost
::graph::python::basic_descriptor<void *,struct 
boost::undirectedS>,struct boost
::graph::python::basic_index_map<struct 
boost::graph::python::basic_descriptor<v
oid *,struct boost::undirectedS>,struct 
boost::adj_list_vertex_property_map<clas
s boost::adjacency_list<struct boost::listS,struct boost::listS,struct 
boost::un
directedS,struct boost::property<enum boost::vertex_index_t,unsigned 
int,struct
boost::no_property>,struct boost::property<enum 
boost::edge_index_t,unsigned int
,struct boost::no_property>,struct boost::no_property,struct 
boost::listS>,unsig
ned int,unsigned int const &,enum boost::vertex_index_t> > > * 
predecessor_map=N
one, class boost::vector_property_map<float,struct 
boost::graph::python::basic_i
ndex_map<struct boost::graph::python::basic_descriptor<void *,struct 
boost::undi
rectedS>,struct boost::adj_list_vertex_property_map<class 
boost::adjacency_list<
struct boost::listS,struct boost::listS,struct boost::undirectedS,struct 
boost::
property<enum boost::vertex_index_t,unsigned int,struct 
boost::no_property>,stru
ct boost::property<enum boost::edge_index_t,unsigned int,struct 
boost::no_proper
ty>,struct boost::no_property,struct boost::listS>,unsigned int,unsigned 
int con
st &,enum boost::vertex_index_t> > > * distance_map=None, class 
boost::vector_pr
operty_map<float,struct boost::graph::python::basic_index_map<struct 
boost::grap
h::python::basic_descriptor<class boost::detail::edge_desc_impl<struct 
boost::un
directed_tag,void *>,struct boost::undirectedS>,struct 
boost::adj_list_edge_prop
erty_map<struct boost::undirected_tag,unsigned int,unsigned int const 
&,void *,s
truct boost::property<enum boost::edge_index_t,unsigned int,struct 
boost::no_pro
perty> const ,enum boost::edge_index_t> > > {lvalue} weight_map, class 
boost::py
thon::api::object visitor=None, class boost::vector_property_map<enum 
boost::def
ault_color_type,struct boost::graph::python::basic_index_map<struct 
boost::graph
::python::basic_descriptor<void *,struct boost::undirectedS>,struct 
boost::adj_l
ist_vertex_property_map<class boost::adjacency_list<struct 
boost::listS,struct b
oost::listS,struct boost::undirectedS,struct boost::property<enum 
boost::vertex_
index_t,unsigned int,struct boost::no_property>,struct 
boost::property<enum boos
t::edge_index_t,unsigned int,struct boost::no_property>,struct 
boost::no_propert
y,struct boost::listS>,unsigned int,unsigned int const &,enum 
boost::vertex_inde
x_t> > > * color_map=None)

Apologies for the line breaks in the formatting above. Windows seems to 
want to make my life difficult.

Thanks,
John.




More information about the Cplusplus-sig mailing list