[PyQt] Attribute type change problem while using Qt 5.12 / PyQt 5.12.1 and wildcard imports

Ümit Öztosun umit at oztosun.net
Wed May 1 10:55:36 BST 2019


Hello,

I have encountered a weird problem using PyQt 5.12.1 and Qt 5.12. Take
the following script:

from PyQt5.QtCore import *
class A(QObject):
    flag = True
a = A()
print a.flag

This outputs QCborSimpleType.True. Boolean attribute somehow converted to
a QCborSimpleType. However, just changing the wildcard import corrects
output:

from PyQt5.QtCore import QObject
class A(QObject):
    flag = True
a = A()
print a.flag

Output is True this time.

I have tried various configurations, here are the wildcard import test
outputs: (Qt/Sip/PyQt all are compiled from source)

Ubuntu 18.04 / Qt-5.12.3 / sip-4.19.16 / PyQt5_gpl-5.12.1
 => QCborSimpleType.True

Ubuntu 18.04 / Qt-5.12.3 / sip-4.19.16 / PyQt5_gpl-5.12.2.dev1904191828
 => QCborSimpleType.True

MacOS 10.14.4 / Qt-5.12.3 / sip-4.19.16 / PyQt5_gpl-5.12.1
 => QCborSimpleType.True

Ubuntu 18.04 / Qt-5.11.3 / sip-4.19.16 / PyQt5_gpl-5.12.1
 => True

Problem only occurs while using Qt-5.12. Using Qt-5.11 brings things to
normal. AFAIK CBOR support was added in Qt 5.12 and this may be related:
https://doc.qt.io/qt-5/whatsnew512.html

Any ideas?

--
Regards,
Umit Oztosun


More information about the PyQt mailing list