[C++-sig] Bug with custom convertor and stl container?

Will Lee lee.will at gmail.com
Mon Jun 19 17:33:53 CEST 2006

I have resolved this problem when I set the template NoProxy to true.
However, another problem comes up when I try to use the map in python:

If I do the following in my unit test:

    def testMap(self):
        amap = atest.AMap()
        amap[3] = 4
        self.assert_(amap[3] == 4)

        # This should not fail?
        for i in amap:
            self.assert_(i.data() == 4)

I'd get a error that looks like:

ERROR: testMap (__main__.ATest)
Traceback (most recent call last):
  File "ATest.py", line 20, in testMap
    self.assert_(i.data() == 4)
TypeError: No Python class registered for C++ class A

Ran 3 tests in 0.005s

FAILED (errors=1)

Note the first assert would pass after I set NoProxy to false, but the
data() call would get me the same error.  The type of "i" is <class '
atest.map_indexing_suite_AMap_entry'>.  Is there a bug in the generated
entry object if I use a custom converter?


On 6/16/06, Ralf W. Grosse-Kunstleve <rwgk at yahoo.com> wrote:
> --- Will Lee <lee.will at gmail.com> wrote:
> > It seems like there's a bug when I use a custom converter (as described
> in
> > the FAQ for the custom string) and a wrapped stl container.  If I define
> a
> > custom converter and use that type in a std::vector or std::map, I'll
> get an
> > "TypeError: No Python class registered for C++" error for that converted
> > type.
> >
> > For example, in the following case where I'm converting from type A to a
> > python integer, std::vector<A> and std::map<int, A> are not working
> > propertly.  The testMap and testVec unit tests will both fail.  This is
> > somewhat a showstopper so it would be great if you have any idea on how
> to
> > get around this.
> You probably have to tell the vector_indexing_suite and the
> map_indexing_suite
> to also return the result of getitem by value. I don't know how to do this
> but
> I believe it is possible.
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060619/011a2e99/attachment.htm>

More information about the Cplusplus-sig mailing list