Hi there,

I've been poking around the thread state API and error/exception
handling, and there's something missing I'd like to see happening.

The only way to retrieve the current exception is via sys.excinfo or
PyErr_GetExcInfo in C. However, the issue is that they don't take a
PyThreadState as argument, but use _PyThreadState_GET() to retrieve the
thread state.

That makes it impossible to retrieve the exception information for a
different thread than the one calling the function.

In order to retrieve the exception from *any* PyThreadState, the caller
has to use _PyErr_GetTopmostException which takes a PyThreadState as
argument — though that function is private and therefore not documented
or usable in an external module (in theory at least).

Should we make _PyErr_GetTopmostException public, or implement something
different to retrieve the top most exception from a PyThreadState?

Cheers,
-- 
Julien Danjou
# Free Software hacker
# https://julien.danjou.info
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/QVMFP76R35SXUIM2WPPVPV5XCVMKPDEB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to