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

PyBuffer_FillInfo returns 'B' buffer, whose behavior has changed w.r.t. 3.1/3.2 #60408

Closed
dvarrazzo mannequin opened this issue Oct 11, 2012 · 3 comments
Closed

PyBuffer_FillInfo returns 'B' buffer, whose behavior has changed w.r.t. 3.1/3.2 #60408

dvarrazzo mannequin opened this issue Oct 11, 2012 · 3 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@dvarrazzo
Copy link
Mannequin

dvarrazzo mannequin commented Oct 11, 2012

BPO 16204
Nosy @vstinner, @dvarrazzo, @skrah
Superseder
  • bpo-15944: memoryviews and ctypes
  • 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 2013-03-23.13:07:43.225>
    created_at = <Date 2012-10-11.23:08:17.209>
    labels = ['type-bug']
    title = "PyBuffer_FillInfo returns 'B' buffer, whose behavior has changed w.r.t. 3.1/3.2"
    updated_at = <Date 2013-03-23.13:07:43.224>
    user = 'https://github.com/dvarrazzo'

    bugs.python.org fields:

    activity = <Date 2013-03-23.13:07:43.224>
    actor = 'skrah'
    assignee = 'none'
    closed = True
    closed_date = <Date 2013-03-23.13:07:43.225>
    closer = 'skrah'
    components = []
    creation = <Date 2012-10-11.23:08:17.209>
    creator = 'piro'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 16204
    keywords = ['3.3regression']
    message_count = 3.0
    messages = ['172710', '185044', '185046']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'piro', 'skrah']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '15944'
    type = 'behavior'
    url = 'https://bugs.python.org/issue16204'
    versions = ['Python 3.3', 'Python 3.4']

    @dvarrazzo
    Copy link
    Mannequin Author

    dvarrazzo mannequin commented Oct 11, 2012

    Definitely related to this change in Python 3.3:

    Accessing a memoryview element with format ‘B’ (unsigned bytes) now 
    returns an integer (in accordance with the struct module syntax). 
    For returning a bytes object the view must be cast to ‘c’ first.
    

    The object returned by PyBuffer_FillInfo is 'B' format: this means that python code finds itself dealing in Py 3.3 with a different object respect to what returned in Py 3.1 and 3.2. Is this change in the behavior wanted? Wouldn't have been better having FillInfo return a 'c' buffer instead?

    I'm adding support to Py 3.3 to psycopg2 and the B buffers make the test suite fail. I want psycopg to return consistent objects across 3.x. Is the change in this commit correct?

    dvarrazzo/psycopg@469b6f8

    Is this a good way to return a 'c' buffer?

    @dvarrazzo dvarrazzo mannequin added the type-bug An unexpected behavior, bug, or error label Oct 11, 2012
    @vstinner
    Copy link
    Member

    @skrah: ping!

    @piro: can't you modify psycopg2 to add conditional code depending on the Python version? IMO the behaviour change is wanted.

    http://www.python.org/dev/peps/pep-3118/

    @skrah
    Copy link
    Mannequin

    skrah mannequin commented Mar 23, 2013

    I've corresponded privately with Daniele Varrazzo about the psycopg2
    issue already and then forgot about this (the psycopg2 fix is good).

    Yes, the change was intentional. There's one open issue (bpo-15944)
    where dabeaz isn't happy about the change, so let's make that a
    superseder.

    @skrah skrah mannequin closed this as completed Mar 23, 2013
    @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
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant