On Wed, Oct 29, 2008 at 3:29 PM, Alex Mohr <[EMAIL PROTECTED]> wrote:
> The documentation isn't great, but the name 'borrowed' is a hint.  Using
> borrowed instructs boost.python that the PyObject * is a borrowed reference.
>  So you can use:
>
> object(handle<>(borrowed(ptr)))
>
> for when ptr is a borrowed reference and
>
> object(handle<>(ptr))
>
> for when ptr is a new reference.
>

That makes a lot more sense. What confused me is this from Dave
Abrahams in a message from Oct 07, I guess he got them mixed up.

If the is not pre-incremented for you, then

        boost::python::handle<> h((PyObject*)callbackID));
        return boost::python::object o(h);

would be correct.  Otherwise, you need

        boost::python::handle<>
h(boost::python::borrowed((PyObject*)callbackID)));
        return boost::python::object o(h);



btw, I notice that object(borrowed(ptr)) compiles and runs without
error. Is handle<>(...) superfluous when using borrowed?

-Dan
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to