Details
Description
We have a singleton metaclass based on type(QtCore.QObject) in the __call__
method we create a new instance of the class and return it
def __call__(self, *args, **kwargs): instance = self.__new__(self, *args, **kwargs) instance.__init__(*args, **kwargs) return instance
or, if you want the one-liner version:
QtCore.QObject.__new__(QtCore.QObject, "", (), {})
the error obtained running this code on Python2 is:
TypeError: PySide2.QtCore.QObject.__new__(PySide2.QtCore.QObject) is not safe, use object.__new__()
the same one-liner works on Python3, I think it is related to PYSIDE-816 and heap types.
Attachments
Issue Links
- relates to
-
PYSIDE-816 Unable to call type(QtWidgets.QWidget).__new__ in Python 2.7
- Closed
-
PYSIDE-1767 Pyside6/Shiboken and ABCMeta Bug
- Reported
For Gerrit Dashboard: PYSIDE-1051 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
272218,9 | Fix heaptype conflict with QtCore.QObject.__new__in Python 2.7 | 5.13 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
273053,2 | Fix heaptype conflict with QtCore.QObject.__new__in Python 2.7 | 5.12 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
275688,1 | Fix heaptype conflict with QtCore.QObject.__new__in Python 2.7 | 5.12.5 | pyside/pyside-setup | Status: ABANDONED | 0 | 0 |