Python doc says
sys.excepthook (type, value, trace)
This function displays the specified trace and exception in sys.stderr.
Thus, this sys.excepthook
is called when an exception is to be printed on the terminal. Now you see that web.py itself handles exceptions. If you do not assign sys.excepthook, the webpage catches the exception and displays the exception in the browser. And since web.py itself handles exceptions, setting sys.excepthook
does not change. If web.py did not handle this exception itself, it would not be sys.excepthook
and sys.excepthook
would be called.
If you really want to handle the exception yourself in this code, try finding the web.py document and source code to find out how web.py handles the exceptions and customizes them.
python doc also says
sys.__excepthook__
These objects contain the initial displayhook and excepthook values ββat the beginning of the program. They are saved so that displayhook and excepthook can be restored if they are replaced by broken objects.
So my guess is web.py, so your custom handler is not called.
Sarim source share