[C++-sig] conversion problem

2008-12-11 Thread Luca Sbardella
My authomatic conversion function from std::pair does not work when one of
the pair type is a boost::python::object.

Template for conversion

template
struct pair_to_tuple  {
typedef pair_to_tuple converter;
typedef std::pair ctype;

static PyObject* convert(ctype const& v)  {
using namespace boost::python;
return incref(make_tuple(v.first,v.second).ptr());
}
static void register_to_python()  {
boost::python::to_python_converter();
}
 };




using namespace boost::python;
pair_to_tuple::register_to_python();   <-
FAILED
pair_to_tuple::register_to_python(); <- OK

The error I get is
*error C2668: 'boost::python::make_tuple' : ambiguous call to overloaded
function
could be 'boost::python::tuple boost::python::make_tuple<_Ty1,_Ty2>(const A0
&,const A1 &)'**
or   'boost::tuples::tuple
boost::tuples::make_tuple<_Ty1,_Ty2>(const T0 &,const T1 &)' [found using
argument-dependent lookup]
*
What I'm I doing wrong?*
*
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

[C++-sig] preventing boost::python::throw_error_already_set

2008-12-11 Thread Leonard Ritter
hi everyone,

i'm having a problem where a boost::python::throw_error_already_set is being
thrown and causes a segfault (linux). unfortunately the error happens from
within python, when reaching the end of an iteration through a vector array,
which was exported using the vector indexing suite.

is there any possibility to catch the previous exception?
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] preventing boost::python::throw_error_already_set

2008-12-11 Thread Stefan Seefeld

Leonard Ritter wrote:

hi everyone,

i'm having a problem where a boost::python::throw_error_already_set is 
being thrown and causes a segfault (linux). unfortunately the error 
happens from within python, when reaching the end of an iteration 
through a vector array, which was exported using the vector indexing 
suite.


is there any possibility to catch the previous exception?


That's hard to tell without more context: Who is doing the iteration, 
for example ?


Regards,
  Stefan

--

 ...ich hab' noch einen Koffer in Berlin...

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig