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

io.BytesIO doesn't support the buffer protocol #49756

Closed
pitrou opened this issue Mar 18, 2009 · 7 comments
Closed

io.BytesIO doesn't support the buffer protocol #49756

pitrou opened this issue Mar 18, 2009 · 7 comments
Labels
stdlib Python modules in the Lib dir topic-IO type-feature A feature request or enhancement

Comments

@pitrou
Copy link
Member

pitrou commented Mar 18, 2009

BPO 5506
Nosy @birkenfeld, @amauryfa, @pitrou, @benjaminp
Files
  • bytesiobuf2.patch
  • 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 2010-09-06.18:50:12.023>
    created_at = <Date 2009-03-18.10:40:11.270>
    labels = ['type-feature', 'library', 'expert-IO']
    title = "io.BytesIO doesn't support the buffer protocol"
    updated_at = <Date 2010-09-06.18:50:12.022>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2010-09-06.18:50:12.022>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-09-06.18:50:12.023>
    closer = 'pitrou'
    components = ['Library (Lib)', 'IO']
    creation = <Date 2009-03-18.10:40:11.270>
    creator = 'pitrou'
    dependencies = []
    files = ['18732']
    hgrepos = []
    issue_num = 5506
    keywords = ['patch']
    message_count = 7.0
    messages = ['83740', '85504', '85507', '115304', '115476', '115479', '115728']
    nosy_count = 4.0
    nosy_names = ['georg.brandl', 'amaury.forgeotdarc', 'pitrou', 'benjamin.peterson']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue5506'
    versions = ['Python 3.2']

    @pitrou
    Copy link
    Member Author

    pitrou commented Mar 18, 2009

    It may be logical for BytesIO to support the buffer protocol (readable
    /and/ writable).

    @pitrou pitrou added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Mar 18, 2009
    @birkenfeld
    Copy link
    Member

    Is this still unimplemented?

    @pitrou
    Copy link
    Member Author

    pitrou commented Apr 5, 2009

    Yes.
    I don't remember which use case I was thinking about when I suggested
    this, but it may be useful to e.g. write() all the data to a file object
    without actually making a copy (getvalue() does).

    @pitrou
    Copy link
    Member Author

    pitrou commented Sep 1, 2010

    Thinking about it, I'm not sure this would be a good idea to do this by default. There is an ambiguity where it's not obvious if the buffer would contain the whole data or only the bytes after the current position.

    I think perhaps an explicit method (getbuffer()?) could be used to export a buffer-compatible object, without copying. Perhaps a memoryview; this would imply defining bf_releasebuffer without bf_getbuffer.

    @pitrou
    Copy link
    Member Author

    pitrou commented Sep 3, 2010

    Here is a patch implementing getbuffer(), together with tests.

    @pitrou
    Copy link
    Member Author

    pitrou commented Sep 3, 2010

    There was an unused "weakreflist" member.

    @pitrou pitrou added the topic-IO label Sep 3, 2010
    @pitrou
    Copy link
    Member Author

    pitrou commented Sep 6, 2010

    This was committed in r84562.

    @pitrou pitrou closed this as completed Sep 6, 2010
    @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
    stdlib Python modules in the Lib dir topic-IO type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants