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

Support buffer protocol with type specs #84901

Closed
scoder opened this issue May 22, 2020 · 5 comments
Closed

Support buffer protocol with type specs #84901

scoder opened this issue May 22, 2020 · 5 comments
Labels
3.9 only security fixes 3.10 only security fixes topic-C-API type-feature A feature request or enhancement

Comments

@scoder
Copy link
Contributor

scoder commented May 22, 2020

BPO 40724
Nosy @pfmoore, @ncoghlan, @pitrou, @scoder, @vstinner, @encukou, @skrah, @miss-islington, @remilapeyre
PRs
  • bpo-40724: Support setting buffer slots from type specs #20648
  • [3.9] bpo-40724: Support setting buffer slots from type specs (GH-20648) #20683
  • bpo-40724: Fix return type of heapctypewithbuffer_releasebuffer() #20685
  • [3.9] bpo-40724: Fix return type of test helper function heapctypewithbuffer_releasebuffer() (GH-20685) #20690
  • 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-06-07.07:29:43.798>
    created_at = <Date 2020-05-22.07:51:02.014>
    labels = ['expert-C-API', 'type-feature', '3.9', '3.10']
    title = 'Support buffer protocol with type specs'
    updated_at = <Date 2020-06-07.07:29:43.797>
    user = 'https://github.com/scoder'

    bugs.python.org fields:

    activity = <Date 2020-06-07.07:29:43.797>
    actor = 'scoder'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-06-07.07:29:43.798>
    closer = 'scoder'
    components = ['C API']
    creation = <Date 2020-05-22.07:51:02.014>
    creator = 'scoder'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40724
    keywords = ['patch']
    message_count = 5.0
    messages = ['369561', '370194', '370849', '370878', '370879']
    nosy_count = 9.0
    nosy_names = ['paul.moore', 'ncoghlan', 'pitrou', 'scoder', 'vstinner', 'petr.viktorin', 'skrah', 'miss-islington', 'remi.lapeyre']
    pr_nums = ['20648', '20683', '20685', '20690']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue40724'
    versions = ['Python 3.9', 'Python 3.10']

    @scoder
    Copy link
    Contributor Author

    scoder commented May 22, 2020

    As far as I can see it in typeslots.h [1], the buffer protocol is still not supported when using type specs:

    /* Disabled, see bpo-10181 */
    #undef Py_bf_getbuffer
    #undef Py_bf_releasebuffer

    It seems that the discussion in bpo-10181 did not lead anywhere at the time (2010-2012).

    I'm not talking about the limited API or the stable ABI here, I'm talking about using type specs to define an extension type. The work-around is to manually set "PyTypeObject->tp_as_buffer" after creating the type, but since PyType_Ready() then does not see that struct pointer, you also still have to make sure that the type correctly inherits the slots from the base type if you're not defining all of them yourself.

    Can we just add support for the above slots?

    [1]

    /* Disabled, see #10181 */
    #undef Py_bf_getbuffer
    #undef Py_bf_releasebuffer

    @scoder scoder added 3.9 only security fixes 3.10 only security fixes topic-C-API type-feature A feature request or enhancement labels May 22, 2020
    @encukou
    Copy link
    Member

    encukou commented May 28, 2020

    Yes, it should be possible to wrap them in #if so they aren't part of the stable ABI.

    @scoder
    Copy link
    Contributor Author

    scoder commented Jun 6, 2020

    New changeset f7c4e23 by scoder in branch 'master':
    bpo-40724: Support setting buffer slots from type specs (GH-20648)
    f7c4e23

    @scoder
    Copy link
    Contributor Author

    scoder commented Jun 7, 2020

    New changeset 1e4fa91 by Miss Islington (bot) in branch '3.9':
    bpo-40724: Support setting buffer slots from type specs (GH-20648) (GH-20683)
    1e4fa91

    @scoder
    Copy link
    Contributor Author

    scoder commented Jun 7, 2020

    New changeset 1d711f2 by Miss Islington (bot) in branch '3.9':
    bpo-40724: Fix return type of test helper function heapctypewithbuffer_releasebuffer() (GH-20685) (GH-20690)
    1d711f2

    @scoder scoder closed this as completed Jun 7, 2020
    @scoder scoder closed this as completed Jun 7, 2020
    @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 topic-C-API type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants