1

I'm trying to write a pyqt5 application. It throws an exception from the Python side in a slot (i.e. callback) that responds to the user clicking a button. I run the application with

python -m pdb myapp.py

which begins with

# myapp.py

import sys
from PyQt5.QtCore import pyqtRemoveInputHook
pyqtRemoveInputHook()

from PyQt5.QtWidgets import QApplication, QWidget
from views import MainWindow
app = QApplication(sys.argv)
main_window = MainWindow()
main_window.show()
sys.exit(app.exec_())

as per this question. I get the debugger prompt at program start and press c to continue. But when the crash happens, I get a stack trace and then a core dump. If I run with ipdb the core dump doesn't happen, but the program locks up before it can drop me into the debugger.

It seems like it's impossible to debug pyqt5 programs if the error is in a callback, although this worked fine in pyqt4 if I recall. How can I get a Python debugger working with pyqt5?

Noah
  • 196
  • 10
  • This may be relevant: [PyQt5 Docs - Unhandled Python Exceptions](http://pyqt.sourceforge.net/Docs/PyQt5/incompatibilities.html#unhandled-python-exceptions). – ekhumoro Jul 22 '17 at 15:57
  • @ekhumoro, that was helpful. I had some luck wrapping Python slots in try/except blocks and doing `ipdb.post_mortem()` in the except block. This gives me access to the stack, but I can't step through it... almost there. – Noah Jul 23 '17 at 20:31

0 Answers0