Details
-
Bug
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.3.0
-
None
Description
If you mistakenly pass a list of strings to a Signal(QObject), Python will crash.
The following PySide6 code snippit will result in a crash. I would expect an exception to be thrown instead of a crash.
from typing import Optional from PySide6.QtCore import QCoreApplication, QObject, QStringListModel, Signal, QTimer from PySide6.QtGui import QColor import sys import signal class MyData(QObject): _color_names: QStringListModel = QStringListModel() _counter = 0 color_names_changed = Signal(QObject) def __init__(self, parent: Optional[QObject] = None) -> None: super().__init__(parent) self._color_names.setStringList(QColor.colorNames()) self._timer = QTimer(self) self._timer.timeout.connect(self.doEmit) self._timer.start(500) def doEmit(self): if self._counter == 5: QCoreApplication.instance().quit() self.color_names_changed.emit(QColor.colorNames()) # Above was a mistake, should have been self.color_names_changed.emit(self._color_names) self._counter += 1 def main() -> int: signal.signal(signal.SIGINT, signal.SIG_DFL) app = QCoreApplication(sys.argv) myData = MyData() app.exec() return 0 if __name__ == "__main__": sys.exit(main())
Attachments
Issue Links
- relates to
-
PYSIDE-1428 Signal does not throw an exception when an incorrect argument is used
-
- Reported
-