Unsupported return type QList<qint64>

Julien Cabieces julien.cabieces at oslandia.com
Mon Jun 24 14:13:03 BST 2024


A non-text attachment was scrubbed...
Name: pyproject.toml
Type: application/octet-stream
Size: 737 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240624/0fd46c0e/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.h
Type: text/x-chdr
Size: 471 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240624/0fd46c0e/attachment.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testmod.sip
Type: application/octet-stream
Size: 380 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240624/0fd46c0e/attachment-0001.obj>
-------------- next part --------------


Hi,

> On 20/06/2024 09:38, Julien Cabieces wrote:
>> Sorry Phil I answered directly to you instead of the list, here is the
>> same message and more.
>> QList is a template mapped type so it should work with other
>> primitive type, no?
>
> No. Mapped type templates only work as templates when type arguments
> are wrapped types. With other type arguments (eg. primitive types)
> they work as template selectors. This is because the Python API is
> different for converting different primitive types.
>
>> It does work with QList<long long> although there
>> is no mapped type
>> provided, and qint64 is nothing more than a long long.
>
> SIP will select a template based on the underlying primitive types
> (ie. after resolving any typedefs) according to the current platform
> and version of Qt. PyQt implements a mapped type for QList<qsizetype>
> when building against Qt v6.5.0 or later. PyQt defines both qint64 and
> qsizetype as long long so it will pick that mapped type for Qt v6.5.0
> or later and fail with earlier versions.
>

thanks for detailed explanations, it's clearer now!

>> Contrary to what I said before, it doesn't look like it's
>> related to different minor version of sip 6.
>> According to my test:
>> - QList<qint64> works with sip 6 on fedora (39, 40) but fails on
>> debian
>> (stable, testing, unstable).
>> - QList<qint64> has never worked with sip 4 (fedora or debian).
>
> You mention PyQt6-Qt6 but this is irrelevant as you aren't building
> against that Qt installation. I assume you are building against the
> distro's Qt installation. 
>

Yes, you're right. I tried also to reproduce the issue with pip to
understand where it was coming from. I tried then with pure fedora and debian
docker, without pip and that's where my test results come from.

> Do Fedora and Debian have different versions
> of Qt?

Yes, they have different versions. For instance:
- Debian:testing  : pyqt6 6.6.1-2 / Qt 6.4.2 / sip 6.8.3 (not
working)
- Debian:unstable : pyqt6 6.7.0-1 / Qt 6.6.2 / sip 6.8.5 (not working)
- fedora:40 : pyqt6 6.7.0-2 / Qt 6.7.1-2 / 6.8.2-2 (working)

As you can see, Debian:unstable and fedora:40 are pretty close in
versions, and both above 6.5.0. Both have the same
qglobal.sip/qtypes.sip declaration regarding qint64. 

The only differences I see are where bindings are stored:
- fedora /usr/lib64/python3.12/site-packages/PyQt6/bindings/
- debian unstable /usr/lib/python3/dist-packages/PyQt6/bindings/QtCore/

And python version

- fedora is python 3.12.3
- debian unstable is 3.11.9.

Does that matter ?

>> Any idea on how to fix this except for a "if debian" directives?
>
> The correct fix is to provide your own QList<qint64> mapped type
> (maybe only with version of Qt older than v6.5).
>

Actually, it doesn't look like related to versions, but more the way
they are packaged.

I added the file I use as example to reproduce the issue, in any case
you spot something odd.


Regards,
Julien


>> Regards,
>> Julien
>> 
>>> On 18/06/2024 14:09, Julien Cabieces wrote:
>>>> Hi,
>>>> When I try to bind a method with a return type QList<qint64>, I get
>>>> the following error
>>>> sip-build: testmod.sip: line 27: column 3: 'Test::testList' has an
>>>> unsupported return type - provide %MethodCode and a C++ signature
>>>> I get this error only with the following installed software:
>>>> PyQt-builder==1.16.2 PyQt6==6.7.0 PyQt6-Qt6==6.7.0 PyQt6-sip==13.6.0
>>>> sip==6.8.3
>>>> and not with
>>>> PyQt-builder==1.15.2 PyQt6==6.6.0 PyQt6-Qt6==6.6.0 PyQt6-sip==13.6.0
>>>> sip==6.7.12
>>>> How can I fix it to match both software versions
>>>> Regards,
>>>> Julien
>>> PyQt doesn't provide a mapped type for QList<qint64> so I don't
>>> understand how it worked with the older versions.
>>> Phil

-- 

Julien Cabieces
Senior Developer at Oslandia
julien.cabieces at oslandia.com


More information about the PyQt mailing list