Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1428

Signal does not throw an exception when an incorrect argument is used

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.1
    • PySide
    • None
    • All

    Description

      When an argument that does not comply with the signature of the signal is used then no exceptions are thrown and it seems that it uses default arguments since in the case that the signature is a string an empty string is sent, and when it is an integer it is sends a 0, generating a silent error that is difficult to track.

       MRE

      import sys
      
      from PySide2.QtCore import QCoreApplication, QObject, Signal, QTimer
      
      
      class Foo(QObject):
          str_sig = Signal(str)
          int_sig = Signal(int)
      
      
      class Bar(QObject):
          def bar_slot(self, val):
              print(val)
      
      
      if __name__ == "__main__":
          app = QCoreApplication(sys.argv)
      
          foo = Foo()
      
          bar = Bar()
      
          foo.str_sig.connect(bar.bar_slot)
          foo.int_sig.connect(bar.bar_slot)
      
          foo.str_sig.emit(10)
          foo.int_sig.emit("fff")
      
          QTimer.singleShot(1000, QCoreApplication.quit)
      
          sys.exit(app.exec_())
      

      Output:

      
      0
      

      Instead in pyqt5 a TypeError exception is thrown.

      Attachments

        Issue Links

          For Gerrit Dashboard: PYSIDE-1428
          # Subject Branch Project Status CR V

          Activity

            People

              crmaurei Cristian Maureira-Fredes
              eyllanesc Edwin Christian Yllanes Cucho
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change