[C++-sig] pybindgen: allow_subclassing option causing reference parameters to be copied?
J. Michael Owen
mikeowen at llnl.gov
Thu Jun 25 02:11:17 CEST 2009
That sounds great to me!
On Jun 24, 2009, at 5:03 PM, Gustavo Carneiro wrote:
>
> I can't really fault your logic.
>
> I just thought of something that makes some sense. If the wrapper
> did something like:
>
> _wrap_my_virtual_method (A &a)
> {
> PyA *py_A;
>
> py_A = PyObject_New(PyA, &PyA_Type);
> py_A->obj = &a;
>
> // --- code to call into Python (without consuming a reference to
> py_A) ---
>
> py_A->obj = NULL;
> Py_DECREF(py_A);
> }
>
> At the end of the virtual method call, if the called python code
> decided to keep a reference to py_A, it will have a py_A with NULL C+
> + object and so any method call on it will crash.
>
> And this would not need any options. It's always best to do the
> smart thing when possible without asking too many questions ;-)
More information about the Cplusplus-sig
mailing list