[Python-Dev] bpo-36829: Add sys.unraisablehook()

Steve Dower steve.dower at python.org
Thu May 16 17:16:49 EDT 2019


On 16May2019 1404, Victor Stinner wrote:
> Le jeu. 16 mai 2019 à 17:56, Steve Dower <steve.dower at python.org> a écrit :
>> I really like this API, and I agree with Victor that we don't really
>> need more than the exception info. For future expansion, we can pass in
>> a different exception, no?
> 
> Sorry, I don't understand. I explained that we need more than
> (exc_type, exc_value, exc_tb).
> 
> "obj" is part of the C function PyErr_WriteUnraisable(). We have to
> pass it to the hook. Otherwise, how do you want to guess where the
> exception comes from? Without any context, it can be super painful to
> debug such exception :-(

You go on to say "pass an error message" and "keep repr(obj) if you 
want", but how is this different from creating an exception that 
contains the custom message, the repr of the object, and chains the 
exception that triggered it?

If you just have a message and no exception at this point, firstly it's 
going against what the hook is documented as doing, but secondly why not 
convert the message into an exception?

Maybe I just missed where you explained how it isn't possible to 
represent an error message as an exception, but I'm pretty sure I can't 
be the only one who will have missed it, so maybe you could explain just 
that one point?

Thanks,
Steve


More information about the Python-Dev mailing list