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

Phil Thompson phil at riverbankcomputing.com
Wed May 1 11:19:04 BST 2019


On 01/05/2019 10:55, Ümit Öztosun wrote:
> 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?

Works fine for me (although I haven't tried it with Python v2). Weird 
things like this are usually build problems, mis-matched versions, old 
things lying around.

Phil


More information about the PyQt mailing list