[C++-sig] [boost.python] Assertion Fails with return_value_policy

Brian Dawn azan00 at yahoo.com
Fri Aug 29 18:59:40 CEST 2008


Thanks everyone for their replies. David you are correct, after ignoring the assertion failure it gave me the information I needed to find the flaw within my code. It was a typo, I had copied and pasted a class exposure line but forgot to actually change the name of the class (such a stupid mistake, but eh better than a major flaw).

The assertion failure can be recreated (on my system at least) with the following two lines of code.
global["class1"] = class_<someClass>("class1");
global["class2"] = class_<someClass>("class2");



----- Original Message ----
From: David Abrahams <dave at boostpro.com>
To: Development of Python/C++ integration <c++-sig at python.org>
Sent: Friday, August 29, 2008 5:18:11 AM
Subject: Re: [C++-sig] [boost.python] Assertion Fails with return_value_policy


on Thu Aug 28 2008, Brian Dawn <azan00-AT-yahoo.com> wrote:

> Hi, I currently have a function that returns an object pointer. I wish to expose
> this function to python. However when I set a return_value_policy to this member
> function I get the following assertion failure.
>
> Assertion failed!
> Program: ...
> File: libs\python\src\converter\registry.cpp
> Line: 207
> Expression: slot->m_to_python == 0

It's hard for me to see how that could be the case.  That assertion
means you've tried to register to-python conversions for the same type
twice.  But the code you show below doesn't look like it should be
registering any type converters, so it seems like the assertion probably
comes from elsewhere (possibly a bug in your code).

If you continue past that assertion (or skip over it in the debugger)
you should observe the Python interpreter giving you the name of the
offending C++ type, but given what I wrote above, I don't expect that to
illuminate much.  More likely it would be very useful to reduce your
code to a minimal, complete example that reproduces the problem.  If you
don't discover a problem in your own code along the way, it will give us
what we need to fix Boost.Python.

I do agree with Stefan that there is a bug in Boost.Python here.  The
problem is that I never decided whether the condition detected by the
assertion should be considered a precondition violation, and documented
it accordingly.  The response to the condition is suboptimal as a
result.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.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/20080829/f49f42d7/attachment.htm>


More information about the Cplusplus-sig mailing list