[Python-Dev] bpo-36829: Add sys.unraisablehook()
Victor Stinner
vstinner at redhat.com
Thu May 16 18:17:00 EDT 2019
Le jeu. 16 mai 2019 à 23:46, Nathaniel Smith <njs at pobox.com> a écrit :
> A clever hook might want the actual object, so it can pretty-print it,
> or open an interactive debugger and let it you examine it, or
> something. Morally this is similar to calling repr(obj), but it
> doesn't literally call repr(obj).
Good point. By the way, I started to use
tracemalloc.get_object_traceback(obj) to display where the object
comes from more and more often :-D It helps me at least in debugging.
So yeah, I would prefer to pass directly the object to the hook.
For example, I'm using it with the "source" parameter of a ResourceWarning:
https://pythondev.readthedocs.io/debug_tools.html#resourcewarning
But also when a buffer underflow or overflow is detected by debug
hooks on Python memory allocators:
https://pythondev.readthedocs.io/debug_tools.html#pythonmalloc-debug
It might also help me sometimes to be able to call
tracemalloc.get_object_traceback(obj) from a custom unraisablehook().
Victor
--
Night gathers, and now my watch begins. It shall not end until my death.
More information about the Python-Dev
mailing list