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?