You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (!PyBuffer_IsContiguous(&dest, 'C') ||dest.ndim>1) {
PyErr_SetString(PyExc_ValueError,
"destination buffer should be contiguous and have at most one dimension");
goto finally;
}
Good catch! I agree we can remove these extra checks.
The ndim bit is likely semantically correct. But very little code in the wild looks for this. FWIW the only code I know actually setting multiple dimensions in a PyBuffer is NumPy.
The former is redundant with what Python does behind the scenes
and the latter isn't needed in practice.
I believe all removed instances were for PyBuffer obtained via
Python's argument parser using `y*` or `w*`.
Closes#124.
In
PyArg_ParseTuple*()
functions, the first condition has been checked.w*
:https://github.com/python/cpython/blob/v3.5.0/Python/getargs.c#L1251
y*
:https://github.com/python/cpython/blob/v3.5.0/Python/getargs.c#L857
https://github.com/python/cpython/blob/v3.5.0/Python/getargs.c#L1306
The second condition is rare, even in Python's Argument Clinic, it is not checked for bytes-like object:
https://github.com/python/cpython/blob/3.9/Modules/clinic/_lzmamodule.c.h#L28-L34
The text was updated successfully, but these errors were encountered: