On Thu, 09 May 2013 07:55:07 +0100, Wichert Akkerman <wichert@wiggy.net> wrote:
That error means the type_id of uuid is not in the bp registry.
I think you can fix this by deriving uuid_to_python from to_python_converter, as demonstrated in the pytype_function example[1]. This will add the get_pytype function call, and on initialisation, should hopefully add what's missing: a call to `registry::lookup`[2].
I'm afraid that doesn't work. To test this I changes my converter struct to derive from bp::converter::wrap_pyttype<&PyStringType> and pass has_get_type=true to the to_python_converter call, but I still get the exact same error.
Fair enough. I see your conversion function doesn't use bp::object, but a raw PyObject instead. Using a bp::object might do the registration for you.. Probably not. Alternatively, you could try adding this to your registration code:-
converter::registration& uuid_converter
= const_cast<converter::registration&>(
converter::registry::lookup(type_id<boost::uuids::uuid>()) );
uuid_converter.m_class_object =
# if PY_VERSION_HEX >= 0x03000000
&PyUnicode_Type;
#else
&PyString_Type;
#endif
That will get you past the current error, at least, but there's probably an easier solution...
HTH,
Alex