2 years ago
#23823

Fitz
Pyside6/Shiboken and ABCMeta Bug
This is specific to the new Pyside6 package. Pyside2 does not have this issue.
When attempting to create an abstract class combining JSON and QObject classes Shiboken throws:
c:\python\python39\lib\abc.py in __new__(mcls, name, bases, namespace, **kwargs)
104 """
105 def __new__(mcls, name, bases, namespace, **kwargs):
--> 106 cls = super().__new__(mcls, name, bases, namespace, **kwargs)
107 _abc_init(cls)
108 return cls
TypeError: Shiboken.ObjectType.__new__(JsonSettingsQtMeta) is not safe, use type.__new__()
Short example:
from abc import ABCMeta
from dataclasses import dataclass
from PySide6.QtCore import QObject
class JsonSettingsQtMeta(ABCMeta, type(QObject)):
def __new__(mcls, name, bases, namespace, **kwargs):
cls = ABCMeta.__new__(mcls, name, bases, namespace, **kwargs)
return cls
class JsonDeserializable:
pass
@dataclass
class DesignVariableContainer(QObject, JsonDeserializable, metaclass=JsonSettingsQtMeta):
pass
I've read through the following bugs, discussions. Attempts to a workaround have failed thus far...
https://bugreports.qt.io/browse/PYSIDE-1051 https://bugreports.qt.io/browse/PYSIDE-816
python-3.x
abc
pyside6
shiboken2
0 Answers
Your Answer