This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2020年05月07日 09:29 by jd, last changed 2022年04月11日 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 19977 | closed | jd, 2020年05月07日 09:32 | |
| PR 19978 | merged | vstinner, 2020年05月07日 09:42 | |
| Messages (10) | |||
|---|---|---|---|
| msg368327 - (view) | Author: Julien Danjou (jd) * | Date: 2020年05月07日 09:29 | |
The function _PyErr_GetTopmostException() is not exported and is useful to get access to exceptions info from a PyThreadState. |
|||
| msg368328 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2020年05月07日 09:43 | |
The function was added by: commit ae3087c6382011c47db82fea4d05f8bbf514265d Author: Mark Shannon <mark@hotpy.org> Date: Sun Oct 22 22:41:51 2017 +0100 Move exc state to generator. Fixes bpo-25612 (#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: commit 0b60f64e4343913b4931dc27379d9808e5b78fe1 Author: Vinay Sajip <vinay_sajip@yahoo.co.uk> Date: Tue Oct 15 08:26:12 2019 +0100 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. |
|||
| msg368332 - (view) | Author: Julien Danjou (jd) * | Date: 2020年05月07日 10:45 | |
I would definitely love to have a public API for this. Would `PyErr_GetTopmostException` be a good candidate for this? (I can open a different bug report if needed) |
|||
| msg368338 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2020年05月07日 13:42 | |
New changeset 8963a7f1f84a05412178b56629508b660d38861b by Victor Stinner in branch 'master': bpo-40545: Export _PyErr_GetTopmostException() function (GH-19978) https://github.com/python/cpython/commit/8963a7f1f84a05412178b56629508b660d38861b |
|||
| msg368339 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2020年05月07日 13:50 | |
> 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. I also recall a minor issue in greenlet: https://github.com/python-greenlet/greenlet/pull/132 |
|||
| msg368340 - (view) | Author: Mark Shannon (Mark.Shannon) * (Python committer) | Date: 2020年05月07日 14:02 | |
What's wrong with `PyErr_GetExcInfo()` for accessing the current exception? Victor, would you revert https://github.com/python/cpython/pull/19978 until we decide what to do. Thanks. |
|||
| msg368341 - (view) | Author: Julien Danjou (jd) * | Date: 2020年05月07日 14:10 | |
PyErr_GetExcInfo() does not allow to specify a PyThreadState as argument. |
|||
| msg368343 - (view) | Author: Mark Shannon (Mark.Shannon) * (Python committer) | Date: 2020年05月07日 14:15 | |
Why do you need to specify a `PyThreadState`? |
|||
| msg368345 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2020年05月07日 14:39 | |
> Why do you need to specify a `PyThreadState`? 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. |
|||
| msg368348 - (view) | Author: Julien Danjou (jd) * | Date: 2020年05月07日 14:53 | |
I confirm what Victor wrote. :) |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:59:30 | admin | set | github: 84725 |
| 2022年01月06日 16:49:34 | iritkatriel | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2020年05月07日 14:53:22 | jd | set | messages: + msg368348 |
| 2020年05月07日 14:39:04 | vstinner | set | messages: + msg368345 |
| 2020年05月07日 14:15:27 | Mark.Shannon | set | messages: + msg368343 |
| 2020年05月07日 14:10:08 | jd | set | messages: + msg368341 |
| 2020年05月07日 14:02:26 | Mark.Shannon | set | messages: + msg368340 |
| 2020年05月07日 13:50:54 | vstinner | set | nosy:
+ scoder, Mark.Shannon messages: + msg368339 |
| 2020年05月07日 13:42:40 | vstinner | set | messages: + msg368338 |
| 2020年05月07日 10:45:43 | jd | set | messages: + msg368332 |
| 2020年05月07日 09:43:44 | vstinner | set | messages: + msg368328 |
| 2020年05月07日 09:42:09 | vstinner | set | nosy:
+ vstinner pull_requests: + pull_request19293 |
| 2020年05月07日 09:32:14 | jd | set | keywords:
+ patch stage: patch review pull_requests: + pull_request19292 |
| 2020年05月07日 09:29:58 | jd | create | |