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_ToContiguous() off-by-one error for non-contiguous buffers #67538

Closed
rhansen mannequin opened this issue Jan 30, 2015 · 4 comments
Closed

PyBuffer_ToContiguous() off-by-one error for non-contiguous buffers #67538

rhansen mannequin opened this issue Jan 30, 2015 · 4 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@rhansen
Copy link
Mannequin

rhansen mannequin commented Jan 30, 2015

BPO 23349
Nosy @skrah
Files
  • PyBuffer_ToContiguous.patch: patch that fixes this bug
  • issue23349-2.diff
  • 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 2015-01-31.14:26:07.054>
    created_at = <Date 2015-01-30.01:07:08.624>
    labels = ['interpreter-core', 'type-bug']
    title = 'PyBuffer_ToContiguous() off-by-one error for non-contiguous buffers'
    updated_at = <Date 2015-01-31.14:26:07.053>
    user = 'https://bugs.python.org/rhansen'

    bugs.python.org fields:

    activity = <Date 2015-01-31.14:26:07.053>
    actor = 'skrah'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-01-31.14:26:07.054>
    closer = 'skrah'
    components = ['Interpreter Core']
    creation = <Date 2015-01-30.01:07:08.624>
    creator = 'rhansen'
    dependencies = []
    files = ['37912', '37927']
    hgrepos = []
    issue_num = 23349
    keywords = ['patch']
    message_count = 4.0
    messages = ['235011', '235042', '235048', '235109']
    nosy_count = 3.0
    nosy_names = ['skrah', 'rhansen', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue23349'
    versions = ['Python 2.7']

    @rhansen
    Copy link
    Mannequin Author

    rhansen mannequin commented Jan 30, 2015

    PyBuffer_ToContiguous() has an off-by-one error when copying a buffer it thinks is non-contiguous.

    To reproduce, put the following in foo.pyx and compile with Cython v0.21.2:

    cpdef foo():
        cdef unsigned char[:] v = bytearray("testing")
        print repr(memoryview(v).tobytes())
    
    >>> import foo
    >>> foo.foo()
    'estingt'

    (This issue was fixed for Python 3.x in issue bpo-12834 but it was not fixed for Python 2.7.)

    @rhansen rhansen mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Jan 30, 2015
    @rhansen rhansen mannequin changed the title memoryview.to_bytes() and PyBuffer_ToContiguous() off-by-one error for non-contiguous buffers PyBuffer_ToContiguous() off-by-one error for non-contiguous buffers Jan 30, 2015
    @skrah
    Copy link
    Mannequin

    skrah mannequin commented Jan 30, 2015

    Looks good, here's a patch with tests.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jan 30, 2015

    New changeset a9305102c892 by Stefan Krah in branch '2.7':
    Issue bpo-23349: Fix off-by-one error in PyBuffer_ToContiguous(). Initial patch
    https://hg.python.org/cpython/rev/a9305102c892

    @skrah
    Copy link
    Mannequin

    skrah mannequin commented Jan 31, 2015

    Should be fixed, thanks for the patch.

    @skrah skrah mannequin closed this as completed Jan 31, 2015
    @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
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants