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

[C API] PyUnicode_CHECK_INTERNED() doesn't work in the limited C API #90165

Closed
vstinner opened this issue Dec 7, 2021 · 3 comments
Closed

[C API] PyUnicode_CHECK_INTERNED() doesn't work in the limited C API #90165

vstinner opened this issue Dec 7, 2021 · 3 comments
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes topic-C-API

Comments

@vstinner
Copy link
Member

vstinner commented Dec 7, 2021

BPO 46007
Nosy @vstinner, @encukou, @miss-islington
PRs
  • bpo-46007: Exclude PyUnicode_CHECK_INTERNED() from limited C API #29987
  • 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 2021-12-09.09:00:19.225>
    created_at = <Date 2021-12-07.17:34:25.875>
    labels = ['expert-C-API', '3.9', '3.10', '3.11']
    title = "[C API] PyUnicode_CHECK_INTERNED() doesn't work in the limited C API"
    updated_at = <Date 2021-12-09.09:00:19.224>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2021-12-09.09:00:19.224>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-12-09.09:00:19.225>
    closer = 'vstinner'
    components = ['C API']
    creation = <Date 2021-12-07.17:34:25.875>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46007
    keywords = ['patch']
    message_count = 3.0
    messages = ['407955', '408007', '408086']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'petr.viktorin', 'miss-islington']
    pr_nums = ['29987']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue46007'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @vstinner
    Copy link
    Member Author

    vstinner commented Dec 7, 2021

    The PyUnicode_CHECK_INTERNED() macro uses the PyASCIIObject structure which is *excluded* from the limited C API:

    /* Use only if you know it's a string */
    #define PyUnicode_CHECK_INTERNED(op) \
        (((PyASCIIObject *)(op))->state.interned)

    Using this macro in the limited C API doesn't work.

    I propose to remove it from the limited C API.

    IMO it's not a good idea to fix the function in the limited C API by converting it to a regular function hiding the implementation details and so working at the ABI level. We should not expose such "implementation detail" (if a string is "interned or not") in the *limited* C API.

    @vstinner vstinner added 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes topic-C-API labels Dec 7, 2021
    @encukou
    Copy link
    Member

    encukou commented Dec 8, 2021

    +1, PyUnicodeObject/PyASCIIObject is excluded from the limited API since Python 3.2, so it wasn't possible to use this macro.

    @miss-islington
    Copy link
    Contributor

    New changeset 73325bb by Victor Stinner in branch 'main':
    bpo-46007: Exclude PyUnicode_CHECK_INTERNED() from limited C API (GH-29987)
    73325bb

    @vstinner vstinner closed this as completed Dec 9, 2021
    @vstinner vstinner closed this as completed Dec 9, 2021
    @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
    Labels
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes topic-C-API
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants