Skip to content
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

Add PyErr_GetActiveException and PyErr_SetActiveException #90501

Closed
iritkatriel opened this issue Jan 11, 2022 · 5 comments
Closed

Add PyErr_GetActiveException and PyErr_SetActiveException #90501

iritkatriel opened this issue Jan 11, 2022 · 5 comments
Assignees
Labels
3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-C-API type-feature A feature request or enhancement

Comments

@iritkatriel
Copy link
Member

BPO 46343
Nosy @asvetlov, @ericsnowcurrently, @iritkatriel
PRs
  • gh-90501: Add PyErr_GetHandledException and PyErr_SetHandledException #30531
  • 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:

    assignee = 'https://github.com/iritkatriel'
    closed_at = None
    created_at = <Date 2022-01-11.12:43:40.822>
    labels = ['interpreter-core', 'expert-C-API', 'type-feature', '3.11']
    title = 'Add PyErr_GetActiveException and PyErr_SetActiveException'
    updated_at = <Date 2022-03-18.14:05:02.526>
    user = 'https://github.com/iritkatriel'

    bugs.python.org fields:

    activity = <Date 2022-03-18.14:05:02.526>
    actor = 'iritkatriel'
    assignee = 'iritkatriel'
    closed = False
    closed_date = None
    closer = None
    components = ['Interpreter Core', 'C API']
    creation = <Date 2022-01-11.12:43:40.822>
    creator = 'iritkatriel'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46343
    keywords = ['patch']
    message_count = 5.0
    messages = ['410299', '410312', '410318', '415491', '415498']
    nosy_count = 3.0
    nosy_names = ['asvetlov', 'eric.snow', 'iritkatriel']
    pr_nums = ['30531']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue46343'
    versions = ['Python 3.11']

    @iritkatriel
    Copy link
    Member Author

    Following the removal of exc_type and exc_traceback from the interpreter's active exception in bpo-45711, 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 bpo-46328 re the corresponding change in the sys module.

    @iritkatriel iritkatriel added the 3.11 only security fixes label Jan 11, 2022
    @iritkatriel iritkatriel self-assigned this Jan 11, 2022
    @iritkatriel iritkatriel added interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-C-API type-feature A feature request or enhancement 3.11 only security fixes labels Jan 11, 2022
    @iritkatriel iritkatriel self-assigned this Jan 11, 2022
    @iritkatriel iritkatriel added interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-C-API type-feature A feature request or enhancement labels Jan 11, 2022
    @ericsnowcurrently
    Copy link
    Member

    Why not PyAPI_FUNC(PyObject *) PyErr_GetActiveException(void);?

    @iritkatriel
    Copy link
    Member Author

    Yes, you’re right of course ;)

    @asvetlov
    Copy link
    Contributor

    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.

    @iritkatriel
    Copy link
    Member Author

    We should make throw accept an exception instance, the same thing was done in the traceback module.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-C-API type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants