-
-
Notifications
You must be signed in to change notification settings - Fork 32k
getargs.c: redundant C-contiguity check #67565
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
Comments
The call to PyBuffer_IsContiguous() (see patch) is redundant: PyBUF_WRITABLE is a flag that can be added to any buffer request. PyBUF_SIMPLE implies C-contiguous with format 'B'. Perhaps the check was added for broken buffer providers, but I |
Do you have unit test with non contiguous buffers? If not, it would help to have such buffer in _testcapi. |
I think memoryview(bytearray)[::2] provides non contiguous buffers. But I'm not sure this is tested. |
Yes, _testbuffer.ndarray can create any buffer. |
A unit test would not be so helpful. The potential problem is that But at some point we have to streamline PEP-3118 code, or it |
Cool. So could you please add non regression tests to test_w_star() of test_getargs2? Other formats expect a contiguous buffer: 'y*', 's*', 'z*'. |
I don't understand the link between third party extensions and |
STINNER Victor wrote:
A test failure needs a broken buffer provider that hands out a non-contiguous The only non-contiguous buffer provider in the stdlib is memoryview. diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c
--- a/Objects/memoryobject.c
+++ b/Objects/memoryobject.c
@@ -1465,11 +1465,6 @@
return -1;
}
if (!REQ_STRIDES(flags)) {
- if (!MV_C_CONTIGUOUS(baseflags)) {
- PyErr_SetString(PyExc_BufferError,
- "memoryview: underlying buffer is not C-contiguous");
- return -1;
- }
view->strides = NULL;
}
if (!REQ_SHAPE(flags)) { ... test_buffer already fails. So what should I test? Perhaps ctypes has If I'm using _testbuffer.ndarray(), I'm effectively testing that the |
Well, here's a patch with tests. Victor, I think you added the contiguity test in 9d49b744078c. Do you |
I don't understand the change like that. The call to PyBuffer_IsContiguous(view, 'C') was older than this changeset. |
Ah yes, it seems to originate from bpo-3139. |
See also contiguity tests in Modules/binascii.c and Modules/_ssl.c, |
(cherry picked from commit 9376728)
Co-authored-by: Stefan Krah <[email protected]>
Co-authored-by: Stefan Krah <[email protected]>
Co-authored-by: Stefan Krah <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
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:
bugs.python.org fields:
Linked PRs
The text was updated successfully, but these errors were encountered: