Details
-
Bug
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.x, 5.15.9
-
None
-
-
fe057b441 (dev), 7c77ccc08 (6.6), c44b7409a (6.5)
Description
It appears that the call signature of callable objects (i.e. objects with a _call_ method that aren't functions or bound methods) is not being correctly inspected during signalInstanceConnect. So, if they accept less arguments than the signal emits, an exception occurs during emit. This is the case with both PySide6 and PySide2, but is not the case with PyQt5/6. It does work, however, if you connect to the
__call__
method directly
Example:
# from PyQt5.QtCore import QObject, pyqtSignal as Signal # works # from PyQt6.QtCore import QObject, pyqtSignal as Signal # works # from PySide2.QtCore import QObject, Signal # breaks from PySide6.QtCore import QObject, Signal # breaks class Emitter(QObject): sig = Signal(int, int) class MyObj: def __call__(self, x: int): print(locals()) emitter = Emitter() obj = MyObj() emitter.sig.connect(obj) # they ALL work if you connect to obj.__call__ emitter.sig.emit(1, 2)
raises
TypeError: MyObj.__call__() takes 2 positional arguments but 3 were given
Attachments
Issue Links
- relates to
-
PYSIDE-2627 Callables inheriting QObject no longer useable as slots in PySide6 6.6.2
-
- Closed
-
Gerrit Reviews
For Gerrit Dashboard: PYSIDE-2423 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
498332,5 | WIP: Handle arguments of callables connected to signals | dev | pyside/pyside-setup | Status: NEW | -2 | 0 |