PyKDL fails to import after PyQt5.QtCore

Dmitry Shachnev mitya57 at ubuntu.com
Tue Mar 16 12:23:43 GMT 2021


Hi Timon!

On Mon, Mar 15, 2021 at 02:23:59PM +0100, Timon Engelke wrote:
> Hey,
>
> I am on Debian Testing and noticed the following error when using PyQt5 and
> PyKDL:
>
> >>> import PyQt5.QtCore
> >>> import PyKDL
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ValueError: PyCapsule_GetPointer called with incorrect name
>
> When I import PyKDL before PyQt5.QtCore, both imports are successful.

Debian maintainer of PyQt5 here, I want to add some debugging information.

PyKDL is an old-style SIP v4 package. The generated PyInit_PyKDL code
contains this line:

    sipAPI_PyKDL = reinterpret_cast<const sipAPIDef *>(PyCapsule_GetPointer(sip_capiobj, "sip._C_API"));

Then, PyCapsule_GetPointer produces the "called with incorrect name" error
when name does not match capsule->name. Here, name is "sip._C_API" and
capsule->name is "PyQt5.sip._C_API".

It looks like this error happens because PyQt5.sip module registers itself
also as "sip" for backwards compatibility:

https://riverbankcomputing.com/hg/sip/file/5.5.0/sipbuild/module/source/12.8/siplib.c#l1237

Maybe Phil can add more details here, but I think the only way to resolve
this will be importing PyKDL before PyQt5.QtCore, until PyKDL gets ported to
a newer SIP version.

--
Dmitry Shachnev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210316/e48067a4/attachment.sig>


More information about the PyQt mailing list