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

ARROW-3228: [Python] Do not allow PyObject_GetBuffer to obtain non-readonly Py_buffer when pyarrow Buffer is not mutable #2567

Closed
wants to merge 1 commit into from

Conversation

@wesm
Copy link
Member

wesm commented Sep 15, 2018

NumPy tries to obtain a writable buffer to determine mutability. This was passing silently:

https://github.com/numpy/numpy/blob/e8d177f74adbe5c7630721a4ab3f20f58839ac99/numpy/core/src/multiarray/ctors.c#L3711

…when pyarrow.Buffer is not writable

Change-Id: I4d644e08e633dd8b6dcc420de9e3d975219d91e0
@wesm

This comment has been minimized.

Copy link
Member Author

wesm commented Sep 15, 2018

if flags & cp.PyBUF_WRITABLE:
raise BufferError("Writable buffer requested but Arrow "
"buffer was not mutable")
buffer.readonly = 1
buffer.buf = <char *>self.buffer.get().data()

This comment has been minimized.

Copy link
@wesm

wesm Sep 15, 2018

Author Member

This cast is evil because it was removing const

@pitrou
pitrou approved these changes Sep 15, 2018
Copy link
Contributor

pitrou left a comment

LGTM.

@wesm wesm closed this in 4121c5a Sep 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.