Using sip.wrappertype as metaclass base does not work
Giuseppe Corbelli
corbelligiuseppe at mesdan.it
Wed Nov 4 11:10:00 GMT 2020
Hi all
quite interesting and obscure (for me) is this behaviour that I found to
be happening on:
Python 3.8.5 / PyQt 5.15.1 / Qt 5.14.2 / sip 4.19.24 / Debian x64
--- NOT WORKING ---
import sip
import PyQt5.QtCore
class CQtSingletonT(sip.wrappertype):
pass
class CQtSingleton(PyQt5.QtCore.QObject, metaclass=CQtSingletonT):
pass
if __name__ == '__main__':
s = CQtSingleton()
TypeError: metaclass conflict: the metaclass of a derived class must be
a (non-strict) subclass of the metaclasses of all its bases
--- NOT WORKING ---
--- WORKING ---
import sip
import PyQt5.QtCore
class CQtSingletonT(type(PyQt5.QtCore.QObject)):
pass
class CQtSingleton(PyQt5.QtCore.QObject, metaclass=CQtSingletonT):
pass
if __name__ == '__main__':
s = CQtSingleton()
--- WORKING ---
What? sip.wrappertype IS the type(QObject) so I'm at loss here.
Note that both versions work well with
Python 3.5.4 / PyQt 5.10.1 / Qt 5.11.2 / sip 4.19.13
Can somebody shed some light on this? I admit I have no idea on what's
going on (except thinking that the metaclass resolution algorithm is
getting fooled somehow, but this does not help much).
Thanks
--
Giuseppe Corbelli
More information about the PyQt
mailing list