You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
commit ae3087c
Author: Mark Shannon <mark@hotpy.org>
Date: Sun Oct 22 22:41:51 2017 +0100
Move exc state to generator. Fixes bpo-25612 (bpo-1773)
Move exception state information from frame objects to coroutine (generator/thread) object where it belongs.
Python 3.9 is now built with -fvisibility=hidden, bpo-11410:
bpo-11410: Standardize and use symbol visibility attributes across POSIX and Windows. (GH-16347)
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.
jd commented on May 7, 2020
jdmannequin
MannequinAuthor
More actions
I would definitely love to have a public API for this.
Would PyErr_GetTopmostException be a good candidate for this?
I would definitely love to have a public API for this.
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.
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.
Activity
jd commentedon May 7, 2020
The function _PyErr_GetTopmostException() is not exported and is useful to get access to exceptions info from a PyThreadState.
vstinner commentedon May 7, 2020
The function was added by:
commit ae3087c
Author: Mark Shannon <mark@hotpy.org>
Date: Sun Oct 22 22:41:51 2017 +0100
Python 3.9 is now built with -fvisibility=hidden, bpo-11410:
commit 0b60f64
Author: Vinay Sajip <vinay_sajip@yahoo.co.uk>
Date: Tue Oct 15 08:26:12 2019 +0100
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.
jd commentedon May 7, 2020
I would definitely love to have a public API for this.
Would
PyErr_GetTopmostExceptionbe a good candidate for this?(I can open a different bug report if needed)
vstinner commentedon May 7, 2020
New changeset 8963a7f by Victor Stinner in branch 'master':
bpo-40545: Export _PyErr_GetTopmostException() function (GH-19978)
8963a7f
vstinner commentedon May 7, 2020
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:
python-greenlet/greenlet#132
markshannon commentedon May 7, 2020
What's wrong with
PyErr_GetExcInfo()for accessing the current exception?Victor, would you revert #19978 until we decide what to do. Thanks.
jd commentedon May 7, 2020
PyErr_GetExcInfo() does not allow to specify a PyThreadState as argument.
markshannon commentedon May 7, 2020
Why do you need to specify a
PyThreadState?vstinner commentedon May 7, 2020
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.
jd commentedon May 7, 2020
I confirm what Victor wrote. :)