[C++-sig] map_indexing_suite does not find to-python convertors

Wichert Akkerman wichert at wiggy.net
Thu Sep 22 17:25:02 CEST 2011


On 09/22/2011 04:50 PM, Wichert Akkerman wrote:
> On 09/22/2011 04:31 PM, Jim Bosch wrote:
>> On 09/22/2011 09:43 AM, Wichert Akkerman wrote:
>>> I am struggling to expose a map to python code. What I am doing is
>>> pretty simple: I have a map from an enum type to Glib::ustring, with a
>>> convertors registered to convert Python str and unicode instances to an
>>> ustring, and ustring to Python unicode. I've put the relevant code 
>>> below.
>>>
>>> What I am running into is that the conversion from python to C++ types
>>> is failing with a "No Python class registered for C++ class
>>> Glib::ustring" error. This looks very similar to the FAQ entry "Why is
>>> my automatic to-python conversion not being found?"
>>> (http://www.boost.org/doc/libs/1_47_0/libs/python/doc/v2/faq.html#topythonconversionfailed 
>>>
>>> ), and the workaround suggested there indeed works fine for class
>>> properties. I can't seem to find a similar trick for map values though.
>>> Is there a trick to get this working?
>>>
>>
>> I think the easiest solution would be to try to switch to indexing 
>> suite v2 (I think the newest version is found in the Py++ sources, 
>> although you don't have to use Py++ to make use of it).  With that, 
>> you can set the call policies for returning elements from your 
>> container.
>
> Is 
> http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/indexing_suite_v2/ 
> the latest version of that? I'll give it a try.

That certainly seems to solve the conversion problem I have been seeing. 
It does have some flaws though, such as find_or_throw  raising a 
ValueError instead of a KeyError when a key is not found in a mapping.

Is there an active bug tracker for the indexing suite where this could 
be filed?

Wichert.




More information about the Cplusplus-sig mailing list