PyQt6 Enum implcit conversion

Julien Cabieces julien.cabieces at oslandia.com
Thu May 25 12:37:58 BST 2023


A non-text attachment was scrubbed...
Name: test.h
Type: text/x-chdr
Size: 241 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20230525/777f1868/attachment.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.sip
Type: application/octet-stream
Size: 276 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20230525/777f1868/attachment.obj>
-------------- next part --------------

Hi,

With SIP/PyQT5 it was possible to pass directly an int to a function
taking an enum as a parameter. It's no longer possible with PyQt6.

For instance, with the following attached sip/header files, in PyQt5 the
following code works :

$ python -c "from test import Test;test=Test();test.printEnum(2)"
others%

While in PyQt6 it display the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: printEnum(self, e: Test.MyEnum): argument 1 has unexpected type 'int'

I understand that the issue is due to the fact that from now enum
inherit from Python enum.Enum type instead of int, but is this behavior
wanted or is it an issue that would be fixed ?

Regards,
Julien


-- 

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


More information about the PyQt mailing list