[PyQt] Crash when sending None in a str signal

Julien Duponchelle julien at gns3.net
Mon Jun 20 09:35:25 BST 2016


Hi,

If you send None instead of a str to a signal the application will
segfault.

Example with this code:

*import sys*
*from PyQt5 import QtCore, QtWidgets*

*class CrashWidget(QtWidgets.QWidget):*
*    crash_signal_int = QtCore.pyqtSignal(int)*
*    crash_signal_str = QtCore.pyqtSignal(str)*

*    def __init__(self):*
*        super().__init__()*
*        self.resize(250, 150)*
*        self.setWindowTitle('Simple')*

*        btn = QtWidgets.QPushButton('Crash', self)*
*        btn.clicked.connect(self._crashApp)*

*    def _crashApp(self):*
*        self.crash_signal_int.emit(None)*
*        print('And crashing with str None...')*
*        self.crash_signal_str.emit(None)*

*def receive_crash_int(integer):*
*    print(integer)*

*def receive_crash_string(string):*
*    print(string)*

*def main():*
*    app = QtWidgets.QApplication(sys.argv)*

*    w = CrashWidget()*
*    w.crash_signal_int.connect(receive_crash_int)*
*    w.crash_signal_str.connect(receive_crash_string)*
*    w.show()*
*    sys.exit(app.exec_())*


*if __name__ == '__main__':*
*    main()*

I know the error is from me but due to the fact it's a segfault it's hard
to locate the issue. It would be easier if a Python exception was raised.

Best regards

Julien Duponchelle
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160620/4effe0c6/attachment.html>


More information about the PyQt mailing list