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.

Title: Add PyErr_GetActiveException and PyErr_SetActiveException
Type: enhancement Stage: patch review
Components: C API, Interpreter Core Versions: Python 3.11
Status: open Resolution:
Dependencies: Superseder:
Assigned To: iritkatriel Nosy List: asvetlov, eric.snow, iritkatriel
Priority: normal Keywords: patch

Created on 2022-01-11 12:43 by iritkatriel, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 30531 open iritkatriel, 2022-01-11 13:09
Messages (5)
msg410299 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-01-11 12:43
Following the removal of exc_type and exc_traceback from the interpreter's active exception in issue45711, we can now provide simplified get-set functions in the C Api:

PyAPI_FUNC(void) PyErr_GetActiveException(PyObject **);
PyAPI_FUNC(void) PyErr_SetActiveException(PyObject *);

as alternatives to 

PyAPI_FUNC(void) PyErr_GetExcInfo(PyObject **, PyObject **, PyObject **);
PyAPI_FUNC(void) PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *);

See also issue46328 re the corresponding change in the sys module.
msg410312 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2022-01-11 16:27
Why not `PyAPI_FUNC(PyObject *) PyErr_GetActiveException(void);`?
msg410318 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-01-11 17:04
Yes, you’re right of course ;)
msg415491 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2022-03-18 12:44
I have a side question.
generator.throw() and coroutine.throw() have throw(type[, value[, traceback]]) signature.

Is there a plan to update generators somehow to accept the exception value only?
The change can go in line with other exception API changes.
msg415498 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-03-18 14:05
We should make throw accept an exception instance, the same thing was done in the traceback module.
Date User Action Args
2022-04-11 14:59:54adminsetgithub: 90501
2022-03-18 14:05:02iritkatrielsetmessages: + msg415498
2022-03-18 12:44:39asvetlovsetnosy: + asvetlov
messages: + msg415491
2022-01-11 17:04:02iritkatrielsetmessages: + msg410318
2022-01-11 16:27:42eric.snowsetnosy: + eric.snow
messages: + msg410312
2022-01-11 13:09:08iritkatrielsetkeywords: + patch
stage: patch review
pull_requests: + pull_request28733
2022-01-11 12:43:40iritkatrielcreate