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


serhiy-storchaka opened this issue Oct 4, 2020 · 3 comments


serhiy-storchaka opened this issue Oct 4, 2020 · 3 comments
3.10 expert-C-API type-feature


Copy link

@serhiy-storchaka serhiy-storchaka commented Oct 4, 2020

BPO 41936
Nosy @gvanrossum, @vstinner, @serhiy-storchaka
  • #22552
  • 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 = None
    closed_at = <Date 2020-10-05.09:32:22.618>
    created_at = <Date 2020-10-04.22:20:31.657>
    labels = ['expert-C-API', 'type-feature', '3.10']
    title = 'Remove macros Py_ALLOW_RECURSION/Py_END_ALLOW_RECURSION'
    updated_at = <Date 2020-10-05.09:32:22.618>
    user = '' fields:

    activity = <Date 2020-10-05.09:32:22.618>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-10-05.09:32:22.618>
    closer = 'serhiy.storchaka'
    components = ['C API']
    creation = <Date 2020-10-04.22:20:31.657>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41936
    keywords = ['patch']
    message_count = 3.0
    messages = ['377978', '378002', '378010']
    nosy_count = 3.0
    nosy_names = ['gvanrossum', 'vstinner', 'serhiy.storchaka']
    pr_nums = ['22552']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = ''
    versions = ['Python 3.10']

    Copy link
    Member Author

    @serhiy-storchaka serhiy-storchaka commented Oct 4, 2020

    Macros Py_ALLOW_RECURSION and Py_END_ALLOW_RECURSION together with field recursion_critical of the PyInterpreterState structure were added in 5b22213 but were never documented. It seems that the reason of adding them was to work around the fact that PyDict_GetItem() can silence any exception including recursion error. But PyDict_GetItem() no longer used in that code and the macros are also no longer used (see bpo-41909).

    GvR proposed to remove these macros. I think that recursion_critical can be removed too.

    @serhiy-storchaka serhiy-storchaka added 3.10 expert-C-API type-feature labels Oct 4, 2020
    Copy link

    @vstinner vstinner commented Oct 5, 2020

    I failed to find users of these macros outside the CPython code base, so it sounds safe to remove it, especially if it's documented in What's New in Python 3.10.

    If someone reports the removal as a regression and describes a legit use case, we can reconsider to revert the removal. Until that, I'm fine with removing them.


    I ran grep on Cython and numpy code base: I cannot find "Py_ALLOW_RECURSION", "Py_END_ALLOW_RECURSION" or "recursion_critical".

    On GitHub, I only found copies of Include/ceval.h (I looked at the first 5 pages of result):

    Copy link
    Member Author

    @serhiy-storchaka serhiy-storchaka commented Oct 5, 2020

    New changeset dcc5421 by Serhiy Storchaka in branch 'master':
    bpo-41936. Remove macros Py_ALLOW_RECURSION/Py_END_ALLOW_RECURSION (GH-22552)

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    3.10 expert-C-API type-feature
    None yet

    No branches or pull requests

    2 participants