[PyQt] Custom exception when transferring "owned" object
Nyall Dawson
nyall.dawson at gmail.com
Fri Apr 5 05:33:55 BST 2019
On Fri, 29 Mar 2019 at 19:59, Phil Thompson <phil at riverbankcomputing.com> wrote:
>
> sipConvertFromType() returns a new reference which you aren't dealing with properly.
>
> You don't need the first call to sipConvertFromType(). Use /GetWrapper/ instead.
>
> sipIsPyOwned() is an undocumented internal function and may be removed at any time.
Is there any way to reconsider this, or add a stable way to retrieve
this information?
> Personally I think trying to add protection in the bindings layer to cover weaknesses in the (current) *implementation* of the C++ API is a mistake (and a never ending task).
I honestly can't see any issue with the c++ api, it's fairly standard
stuff. The next step after this would be to modernize the c++ api to
use unique_ptrs instead of raw pointers. It's then only in the Python
-> c++ conversion that ownership issues can arise, which I'm trying to
find a way to avoid. A hard crash is not a nice experience for
beginners starting out with our Python API, and the explanation on why
these occur veers way to heavily into the guts of c++ memory
management for my comfort. That's why I'd love to find a stable way to
instead raise exceptions, which at least is the expected behaviour for
Python devs.
Nyall
More information about the PyQt
mailing list