-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose _PyErr_GetTopmostException #84725
Comments
The function _PyErr_GetTopmostException() is not exported and is useful to get access to exceptions info from a PyThreadState. |
The function was added by: commit ae3087c
Python 3.9 is now built with -fvisibility=hidden, bpo-11410: commit 0b60f64
It means that functions which are not explicitly exported are no longer exported. So yeah, _PyErr_GetTopmostException() symbol is not properly exported. But the function remains private. IMHO if someone wants to add a *public* function, it should return a *strong* reference to the 3 variables (exc type, exc value, exc tb). See also bpo-39947: "[C API] Make the PyThreadState structure opaque (move it to the internal C API)". I added multiple public getters for PyThreadState structure in Python 3.9. |
I would definitely love to have a public API for this. Would (I can open a different bug report if needed) |
I'm not sure if it's a good idea. It's kind of semi-internal. Stephan Behnel and Mark Shannon: What do you think of exposing PyThreadState exception stack (exc_state)? Especially the "top" exception. If I recall correctly, Mark designed it and Stephan "reimplemented" it in Cython. I also recall a minor issue in greenlet: |
What's wrong with Victor, would you revert #19978 until we decide what to do. Thanks. |
PyErr_GetExcInfo() does not allow to specify a PyThreadState as argument. |
Why do you need to specify a |
From past issues, I understood that Julien's use case is a profiler which inspects memory without calling functions nor switching to other threads. It's like "dump the state of all Python threads". I'm fine with exposing _PyErr_GetTopmostException() as a *private* function. Moreover, the function was already exposed in 3.8. It was not exposed because of the visibility change which was made in 3.9. |
I confirm what Victor wrote. :) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: