[C++-sig] Help with converters ...

Michele De Stefano micdestefano at gmail.com
Mon Oct 19 17:34:35 CEST 2009


Hello to everyone.

I'm stuck with this problem. I'm trying to write a "from Python
converter", from a tuple(tuple,tuple) type to C++.
Clarifying more, the Python type is a tuple, containing 2 tuples.

Now, when I try to implement the "convertible" static member function
of the converter class, I write this (I've extracted only the
interesting part):

static void* convertible(PyObject* obj_ptr) {
		
	using namespace boost::python;

	handle<>	hndl(borrowed(obj_ptr));
	object	in(hndl);
		
	if (!PyTuple_Check(in.ptr())) return NULL;
		
	extract<const tuple&>
             get_tup0(in[0]),
             get_tup1(in[1]);
		
        bool
	     t1 = get_tup0.check(),
	     t2 = get_tup1.check();

...... the rest of the code is not necessary ....


The problem is that even if I pass a tuple containing two tuples from
Python, t1 and t2 become "false".
Surely I'm not interfacing properly with Python, but I don't understand why.

Can someone help me to understand ?

Thank you in advance.
Michele


-- 
Michele De Stefano
http://www.linkedin.com/in/micdestefano
http://xoomer.virgilio.it/michele_de_stefano


More information about the Cplusplus-sig mailing list