My app use QT for the gui layer, and many other lib I made.
One of this other lib is quite complex (it’s a type system) and full of asserts to make it as solid as possible.
But when an assert is triggered in this lib, the Qt mainloop simply continue.
I have a qt_debug() that works well (with pyqtRemoveInputHook) for the Qt part but nothing for the rest of python libraries.
And, obviously I would avoid to change code in the library as it should useable without Qt.
The best solution would be an assert hook, but despite googling around I didn’t any obvious way to do it. Any idea ?
Using
assertis the wrong way. For one thing, if Python is run with -O (or -OO)asserts are turned off; for another, the error message is not very helpful. That library needs to be redesigned to properly use exceptions.As far as using the library as it stands: what do you want to have happen? Should your app quit? If so, you could create your own AssertionError class, replace the one in
__builtins__with yours, and have it do whatever you want in its__init__. Note that you are completely on your own if you do this.