On 2/6/2014, 5:34 PM, Victor Stinner wrote:
Install an handler for unhandled exceptions is not something new: there is
already sys.displayhook and sys.excepthook.
I'm not sure that it's useful to get the "default" handler. Just give
access to the current handler. So when you setup a new handler, just call
the previous if you don't know what to do with it. It is the design chosen
for the new malloc API, PEP 445. So you just need two function: get and
set.
For sys.displayhook/excepthook, the default is stored in
sys.__displayhook/excepthook__.
Victor
You're right, it's nothing new. However, I always hated the need
to save old hook, attach new one, then at some point restore the
old one. This explicit management of the old hook is almost never
gives you anything good. Yes, you have an option of stacking the
hooks on top of each other, but this is also rarely used. To me,
having an option to reset to or get the default hook looks
simpler. And, if needed, we can always add 'get_exception_handler'
to the spec later, right?
Yury