[PyQt] New exception in Python 3.7.4 when bad code tries to PyQt5.uic.loadUi()

Kyle Altendorf sda at fstab.net
Sat Aug 3 19:38:51 BST 2019


I have many custom widgets with pyqtProperty's and GUI elements loaded 
from .ui files.  In various ways, my existing code tries to access 
not-yet-present attributes in pyqtProperty's while the .ui is being 
loaded.  This is obviously bad and I plan to fix my code.  I share this 
example because I already finished it and because this is an odd change 
of behavior from a micro version bump of Python.  Also, it is odd that 
each first time my code raises an exception there is not necessarily a 
Qt failure.  For example, WidgetB must be constructed twice to get the 
traceback.  I understand that this may well not get 'fixed' since it 
probably never should have worked to begin with.

Code and output from 3.7.3/3.7.4 on Linux/Windows are attached and also 
available at:
     https://gist.github.com/altendky/f15f8d180269a4080c25dec83cf556a0

Here is the basic traceback:

     AttributeError: __getattribute__

     The above exception was the direct cause of the following exception:

     Traceback (most recent call last):
       File "bad.py", line 146, in main
         widgets.append(WidgetA(broken=True))
       File "bad.py", line 53, in __init__
         PyQt5.uic.loadUi(io.StringIO(ui_text), self)
       File 
"C:\epc\bug\venv3.7-32\lib\site-packages\PyQt5\uic\__init__.py", line 
227, in loadUi
         return DynamicUILoader(package).loadUi(uifile, baseinstance, 
resource_suffix)
       File 
"C:\epc\bug\venv3.7-32\lib\site-packages\PyQt5\uic\Loader\loader.py", 
line 72, in loadUi
         return self.parse(filename, resource_suffix, basedir)
       File 
"C:\epc\bug\venv3.7-32\lib\site-packages\PyQt5\uic\uiparser.py", line 
1030, in parse
         actor(elem)
       File 
"C:\epc\bug\venv3.7-32\lib\site-packages\PyQt5\uic\uiparser.py", line 
942, in createConnections
         QtCore.QMetaObject.connectSlotsByName(self.toplevelWidget)
     SystemError: <built-in function connectSlotsByName> returned a 
result with an error set

Cheers,
-kyle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bad.py
Type: text/x-c++
Size: 3557 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190803/d09f5aba/attachment.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: linux_3.7.3
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190803/d09f5aba/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: linux_3.7.4
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190803/d09f5aba/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: windows_3.7.3
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190803/d09f5aba/attachment-0002.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: windows_3.7.4
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190803/d09f5aba/attachment-0003.ksh>


More information about the PyQt mailing list