gh-67565: Remove redundant C-contiguity checks (GH-105521)

Co-authored-by: Stefan Krah <skrah@bytereef.org>
This commit is contained in:
Furkan Onder 2023-10-23 12:54:46 +03:00 committed by GitHub
parent c84b0390c0
commit 32c37fe1ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 36 additions and 464 deletions

View File

@ -0,0 +1 @@
Remove redundant C-contiguity check in :file:`getargs.c`, :mod:`binascii`, :mod:`ssl` and Argument Clinic. Patched by Stefan Krah and Furkan Onder

View File

@ -98,10 +98,6 @@ skip_optional_posonly:
if (PyObject_GetBuffer(fastargs[2], &key, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&key, 'C')) {
_PyArg_BadArgument("blake2b", "argument 'key'", "contiguous buffer", fastargs[2]);
goto exit;
}
if (!--noptargs) {
goto skip_optional_kwonly;
}
@ -110,10 +106,6 @@ skip_optional_posonly:
if (PyObject_GetBuffer(fastargs[3], &salt, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&salt, 'C')) {
_PyArg_BadArgument("blake2b", "argument 'salt'", "contiguous buffer", fastargs[3]);
goto exit;
}
if (!--noptargs) {
goto skip_optional_kwonly;
}
@ -122,10 +114,6 @@ skip_optional_posonly:
if (PyObject_GetBuffer(fastargs[4], &person, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&person, 'C')) {
_PyArg_BadArgument("blake2b", "argument 'person'", "contiguous buffer", fastargs[4]);
goto exit;
}
if (!--noptargs) {
goto skip_optional_kwonly;
}
@ -277,4 +265,4 @@ _blake2_blake2b_hexdigest(BLAKE2bObject *self, PyObject *Py_UNUSED(ignored))
{
return _blake2_blake2b_hexdigest_impl(self);
}
/*[clinic end generated code: output=19b82b55c033d895 input=a9049054013a1b77]*/
/*[clinic end generated code: output=e18eeaee40623bfc input=a9049054013a1b77]*/

View File

@ -98,10 +98,6 @@ skip_optional_posonly:
if (PyObject_GetBuffer(fastargs[2], &key, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&key, 'C')) {
_PyArg_BadArgument("blake2s", "argument 'key'", "contiguous buffer", fastargs[2]);
goto exit;
}
if (!--noptargs) {
goto skip_optional_kwonly;
}
@ -110,10 +106,6 @@ skip_optional_posonly:
if (PyObject_GetBuffer(fastargs[3], &salt, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&salt, 'C')) {
_PyArg_BadArgument("blake2s", "argument 'salt'", "contiguous buffer", fastargs[3]);
goto exit;
}
if (!--noptargs) {
goto skip_optional_kwonly;
}
@ -122,10 +114,6 @@ skip_optional_posonly:
if (PyObject_GetBuffer(fastargs[4], &person, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&person, 'C')) {
_PyArg_BadArgument("blake2s", "argument 'person'", "contiguous buffer", fastargs[4]);
goto exit;
}
if (!--noptargs) {
goto skip_optional_kwonly;
}
@ -277,4 +265,4 @@ _blake2_blake2s_hexdigest(BLAKE2sObject *self, PyObject *Py_UNUSED(ignored))
{
return _blake2_blake2s_hexdigest_impl(self);
}
/*[clinic end generated code: output=79b3479e90f4d077 input=a9049054013a1b77]*/
/*[clinic end generated code: output=24690e4e2586cafd input=a9049054013a1b77]*/

View File

@ -30,10 +30,6 @@ _io__BufferedIOBase_readinto(PyObject *self, PyObject *arg)
_PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = _io__BufferedIOBase_readinto_impl(self, &buffer);
exit:
@ -66,10 +62,6 @@ _io__BufferedIOBase_readinto1(PyObject *self, PyObject *arg)
_PyArg_BadArgument("readinto1", "argument", "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto1", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = _io__BufferedIOBase_readinto1_impl(self, &buffer);
exit:
@ -592,10 +584,6 @@ _io__Buffered_readinto(buffered *self, PyObject *arg)
_PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = _io__Buffered_readinto_impl(self, &buffer);
exit:
@ -628,10 +616,6 @@ _io__Buffered_readinto1(buffered *self, PyObject *arg)
_PyArg_BadArgument("readinto1", "argument", "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto1", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = _io__Buffered_readinto1_impl(self, &buffer);
exit:
@ -945,10 +929,6 @@ _io_BufferedWriter_write(buffered *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("write", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = _io_BufferedWriter_write_impl(self, &buffer);
exit:
@ -1095,4 +1075,4 @@ skip_optional_pos:
exit:
return return_value;
}
/*[clinic end generated code: output=b83f65fad0cd5fb6 input=a9049054013a1b77]*/
/*[clinic end generated code: output=090e70253e35fc22 input=a9049054013a1b77]*/

View File

@ -332,10 +332,6 @@ _io_BytesIO_readinto(bytesio *self, PyObject *arg)
_PyArg_BadArgument("readinto", "argument", "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = _io_BytesIO_readinto_impl(self, &buffer);
exit:
@ -538,4 +534,4 @@ skip_optional_pos:
exit:
return return_value;
}
/*[clinic end generated code: output=27333725edff70a0 input=a9049054013a1b77]*/
/*[clinic end generated code: output=2be0e05a8871b7e2 input=a9049054013a1b77]*/

View File

@ -249,10 +249,6 @@ _io_FileIO_readinto(fileio *self, PyTypeObject *cls, PyObject *const *args, Py_s
_PyArg_BadArgument("readinto", "argument 1", "read-write bytes-like object", args[0]);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
return_value = _io_FileIO_readinto_impl(self, cls, &buffer);
exit:
@ -381,10 +377,6 @@ _io_FileIO_write(fileio *self, PyTypeObject *cls, PyObject *const *args, Py_ssiz
if (PyObject_GetBuffer(args[0], &b, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&b, 'C')) {
_PyArg_BadArgument("write", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
return_value = _io_FileIO_write_impl(self, cls, &b);
exit:
@ -536,4 +528,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored))
#ifndef _IO_FILEIO_TRUNCATE_METHODDEF
#define _IO_FILEIO_TRUNCATE_METHODDEF
#endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */
/*[clinic end generated code: output=10838003d15e7b3d input=a9049054013a1b77]*/
/*[clinic end generated code: output=1c0f4a36f76b0c6a input=a9049054013a1b77]*/

View File

@ -247,10 +247,6 @@ _io__WindowsConsoleIO_readinto(winconsoleio *self, PyTypeObject *cls, PyObject *
_PyArg_BadArgument("readinto", "argument 1", "read-write bytes-like object", args[0]);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
return_value = _io__WindowsConsoleIO_readinto_impl(self, cls, &buffer);
exit:
@ -391,10 +387,6 @@ _io__WindowsConsoleIO_write(winconsoleio *self, PyTypeObject *cls, PyObject *con
if (PyObject_GetBuffer(args[0], &b, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&b, 'C')) {
_PyArg_BadArgument("write", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
return_value = _io__WindowsConsoleIO_write_impl(self, cls, &b);
exit:
@ -465,4 +457,4 @@ _io__WindowsConsoleIO_isatty(winconsoleio *self, PyObject *Py_UNUSED(ignored))
#ifndef _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
#define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
#endif /* !defined(_IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF) */
/*[clinic end generated code: output=2debef253fa1ab90 input=a9049054013a1b77]*/
/*[clinic end generated code: output=04108fc26b187386 input=a9049054013a1b77]*/

View File

@ -104,10 +104,6 @@ _multiprocessing_send(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[1], &buf, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&buf, 'C')) {
_PyArg_BadArgument("send", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
return_value = _multiprocessing_send_impl(module, handle, &buf);
exit:
@ -168,4 +164,4 @@ exit:
#ifndef _MULTIPROCESSING_SEND_METHODDEF
#define _MULTIPROCESSING_SEND_METHODDEF
#endif /* !defined(_MULTIPROCESSING_SEND_METHODDEF) */
/*[clinic end generated code: output=48504f7a2d37958c input=a9049054013a1b77]*/
/*[clinic end generated code: output=73b4cb8428d816da input=a9049054013a1b77]*/

View File

@ -88,10 +88,6 @@ blob_write(pysqlite_Blob *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("write", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = blob_write_impl(self, &data);
exit:
@ -215,4 +211,4 @@ blob_exit(pysqlite_Blob *self, PyObject *const *args, Py_ssize_t nargs)
exit:
return return_value;
}
/*[clinic end generated code: output=27c24afc687bd772 input=a9049054013a1b77]*/
/*[clinic end generated code: output=31abd55660e0c5af input=a9049054013a1b77]*/

View File

@ -1557,10 +1557,6 @@ deserialize(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs,
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("deserialize", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
}
if (!noptargs) {
goto skip_optional_kwonly;
@ -1822,4 +1818,4 @@ exit:
#ifndef DESERIALIZE_METHODDEF
#define DESERIALIZE_METHODDEF
#endif /* !defined(DESERIALIZE_METHODDEF) */
/*[clinic end generated code: output=b9c27a406e329587 input=a9049054013a1b77]*/
/*[clinic end generated code: output=90b5b9c14261b8d7 input=a9049054013a1b77]*/

View File

@ -4133,7 +4133,8 @@ _ssl__SSLContext_load_verify_locations_impl(PySSLContext *self,
if (PyObject_GetBuffer(cadata, &buf, PyBUF_SIMPLE)) {
goto error;
}
if (!PyBuffer_IsContiguous(&buf, 'C') || buf.ndim > 1) {
assert(PyBuffer_IsContiguous(&buf, 'C'));
if (buf.ndim > 1) {
PyBuffer_Release(&buf);
PyErr_SetString(PyExc_TypeError,
"cadata should be a contiguous buffer with "

View File

@ -185,13 +185,7 @@ ascii_buffer_converter(PyObject *arg, Py_buffer *buf)
"not '%.100s'", Py_TYPE(arg)->tp_name);
return 0;
}
if (!PyBuffer_IsContiguous(buf, 'C')) {
PyErr_Format(PyExc_TypeError,
"argument should be a contiguous buffer, "
"not '%.100s'", Py_TYPE(arg)->tp_name);
PyBuffer_Release(buf);
return 0;
}
assert(PyBuffer_IsContiguous(buf, 'C'));
return Py_CLEANUP_SUPPORTED;
}

View File

@ -154,10 +154,6 @@ _multibytecodec_MultibyteCodec_decode(MultibyteCodecObject *self, PyObject *cons
if (PyObject_GetBuffer(args[0], &input, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&input, 'C')) {
_PyArg_BadArgument("decode", "argument 'input'", "contiguous buffer", args[0]);
goto exit;
}
if (!noptargs) {
goto skip_optional_pos;
}
@ -374,10 +370,6 @@ _multibytecodec_MultibyteIncrementalDecoder_decode(MultibyteIncrementalDecoderOb
if (PyObject_GetBuffer(args[0], &input, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&input, 'C')) {
_PyArg_BadArgument("decode", "argument 'input'", "contiguous buffer", args[0]);
goto exit;
}
if (!noptargs) {
goto skip_optional_pos;
}
@ -690,4 +682,4 @@ PyDoc_STRVAR(_multibytecodec___create_codec__doc__,
#define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \
{"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__},
/*[clinic end generated code: output=38f8d42721eea1e6 input=a9049054013a1b77]*/
/*[clinic end generated code: output=219a363662d2fbff input=a9049054013a1b77]*/

View File

@ -35,10 +35,6 @@ _bz2_BZ2Compressor_compress(BZ2Compressor *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("compress", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = _bz2_BZ2Compressor_compress_impl(self, &data);
exit:
@ -181,10 +177,6 @@ _bz2_BZ2Decompressor_decompress(BZ2Decompressor *self, PyObject *const *args, Py
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("decompress", "argument 'data'", "contiguous buffer", args[0]);
goto exit;
}
if (!noptargs) {
goto skip_optional_pos;
}
@ -242,4 +234,4 @@ _bz2_BZ2Decompressor(PyTypeObject *type, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
/*[clinic end generated code: output=90f7b5c451c0a8bf input=a9049054013a1b77]*/
/*[clinic end generated code: output=8daa62f47cc4853d input=a9049054013a1b77]*/

View File

@ -303,10 +303,6 @@ _codecs_escape_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("escape_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
}
if (nargs < 2) {
goto skip_optional;
@ -422,10 +418,6 @@ _codecs_utf_7_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("utf_7_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -492,10 +484,6 @@ _codecs_utf_8_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("utf_8_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -562,10 +550,6 @@ _codecs_utf_16_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("utf_16_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -632,10 +616,6 @@ _codecs_utf_16_le_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("utf_16_le_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -702,10 +682,6 @@ _codecs_utf_16_be_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("utf_16_be_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -774,10 +750,6 @@ _codecs_utf_16_ex_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("utf_16_ex_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -851,10 +823,6 @@ _codecs_utf_32_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("utf_32_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -921,10 +889,6 @@ _codecs_utf_32_le_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("utf_32_le_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -991,10 +955,6 @@ _codecs_utf_32_be_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("utf_32_be_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -1063,10 +1023,6 @@ _codecs_utf_32_ex_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("utf_32_ex_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -1149,10 +1105,6 @@ _codecs_unicode_escape_decode(PyObject *module, PyObject *const *args, Py_ssize_
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("unicode_escape_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
}
if (nargs < 2) {
goto skip_optional;
@ -1229,10 +1181,6 @@ _codecs_raw_unicode_escape_decode(PyObject *module, PyObject *const *args, Py_ss
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("raw_unicode_escape_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
}
if (nargs < 2) {
goto skip_optional;
@ -1299,10 +1247,6 @@ _codecs_latin_1_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("latin_1_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -1361,10 +1305,6 @@ _codecs_ascii_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("ascii_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -1424,10 +1364,6 @@ _codecs_charmap_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("charmap_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -1493,10 +1429,6 @@ _codecs_mbcs_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("mbcs_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -1567,10 +1499,6 @@ _codecs_oem_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("oem_decode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -1646,10 +1574,6 @@ _codecs_code_page_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar
if (PyObject_GetBuffer(args[1], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("code_page_decode", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
if (nargs < 3) {
goto skip_optional;
}
@ -1726,10 +1650,6 @@ _codecs_readbuffer_encode(PyObject *module, PyObject *const *args, Py_ssize_t na
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("readbuffer_encode", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
}
if (nargs < 2) {
goto skip_optional;
@ -2818,4 +2738,4 @@ exit:
#ifndef _CODECS_CODE_PAGE_ENCODE_METHODDEF
#define _CODECS_CODE_PAGE_ENCODE_METHODDEF
#endif /* !defined(_CODECS_CODE_PAGE_ENCODE_METHODDEF) */
/*[clinic end generated code: output=40cf63bf2da18359 input=a9049054013a1b77]*/
/*[clinic end generated code: output=d8d9e372f7ccba35 input=a9049054013a1b77]*/

View File

@ -1290,17 +1290,9 @@ pbkdf2_hmac(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
if (PyObject_GetBuffer(args[1], &password, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&password, 'C')) {
_PyArg_BadArgument("pbkdf2_hmac", "argument 'password'", "contiguous buffer", args[1]);
goto exit;
}
if (PyObject_GetBuffer(args[2], &salt, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&salt, 'C')) {
_PyArg_BadArgument("pbkdf2_hmac", "argument 'salt'", "contiguous buffer", args[2]);
goto exit;
}
iterations = PyLong_AsLong(args[3]);
if (iterations == -1 && PyErr_Occurred()) {
goto exit;
@ -1388,10 +1380,6 @@ _hashlib_scrypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj
if (PyObject_GetBuffer(args[0], &password, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&password, 'C')) {
_PyArg_BadArgument("scrypt", "argument 'password'", "contiguous buffer", args[0]);
goto exit;
}
if (!noptargs) {
goto skip_optional_kwonly;
}
@ -1399,10 +1387,6 @@ _hashlib_scrypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj
if (PyObject_GetBuffer(args[1], &salt, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&salt, 'C')) {
_PyArg_BadArgument("scrypt", "argument 'salt'", "contiguous buffer", args[1]);
goto exit;
}
if (!--noptargs) {
goto skip_optional_kwonly;
}
@ -1522,17 +1506,9 @@ _hashlib_hmac_singleshot(PyObject *module, PyObject *const *args, Py_ssize_t nar
if (PyObject_GetBuffer(args[0], &key, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&key, 'C')) {
_PyArg_BadArgument("hmac_digest", "argument 'key'", "contiguous buffer", args[0]);
goto exit;
}
if (PyObject_GetBuffer(args[1], &msg, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&msg, 'C')) {
_PyArg_BadArgument("hmac_digest", "argument 'msg'", "contiguous buffer", args[1]);
goto exit;
}
digest = args[2];
return_value = _hashlib_hmac_singleshot_impl(module, &key, &msg, digest);
@ -1604,10 +1580,6 @@ _hashlib_hmac_new(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyO
if (PyObject_GetBuffer(args[0], &key, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&key, 'C')) {
_PyArg_BadArgument("hmac_new", "argument 'key'", "contiguous buffer", args[0]);
goto exit;
}
if (!noptargs) {
goto skip_optional_pos;
}
@ -1852,4 +1824,4 @@ exit:
#ifndef _HASHLIB_SCRYPT_METHODDEF
#define _HASHLIB_SCRYPT_METHODDEF
#endif /* !defined(_HASHLIB_SCRYPT_METHODDEF) */
/*[clinic end generated code: output=21ad88d46922dc00 input=a9049054013a1b77]*/
/*[clinic end generated code: output=b7eddeb3d6ccdeec input=a9049054013a1b77]*/

View File

@ -35,10 +35,6 @@ _lzma_LZMACompressor_compress(Compressor *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("compress", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = _lzma_LZMACompressor_compress_impl(self, &data);
exit:
@ -139,10 +135,6 @@ _lzma_LZMADecompressor_decompress(Decompressor *self, PyObject *const *args, Py_
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("decompress", "argument 'data'", "contiguous buffer", args[0]);
goto exit;
}
if (!noptargs) {
goto skip_optional_pos;
}
@ -325,10 +317,6 @@ _lzma__decode_filter_properties(PyObject *module, PyObject *const *args, Py_ssiz
if (PyObject_GetBuffer(args[1], &encoded_props, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&encoded_props, 'C')) {
_PyArg_BadArgument("_decode_filter_properties", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
return_value = _lzma__decode_filter_properties_impl(module, filter_id, &encoded_props);
exit:
@ -339,4 +327,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=fca7d2b5800dc4c1 input=a9049054013a1b77]*/
/*[clinic end generated code: output=5e79c05ace76dc96 input=a9049054013a1b77]*/

View File

@ -237,10 +237,6 @@ _ssl__SSLSocket_write(PySSLSocket *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&b, 'C')) {
_PyArg_BadArgument("write", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = _ssl__SSLSocket_write_impl(self, &b);
exit:
@ -530,10 +526,6 @@ _ssl__SSLContext__set_alpn_protocols(PySSLContext *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &protos, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&protos, 'C')) {
_PyArg_BadArgument("_set_alpn_protocols", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = _ssl__SSLContext__set_alpn_protocols_impl(self, &protos);
exit:
@ -1108,10 +1100,6 @@ _ssl_MemoryBIO_write(PySSLMemoryBIO *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&b, 'C')) {
_PyArg_BadArgument("write", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = _ssl_MemoryBIO_write_impl(self, &b);
exit:
@ -1180,10 +1168,6 @@ _ssl_RAND_add(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[0], &view, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&view, 'C')) {
_PyArg_BadArgument("RAND_add", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
}
if (PyFloat_CheckExact(args[1])) {
entropy = PyFloat_AS_DOUBLE(args[1]);
@ -1543,4 +1527,4 @@ exit:
#ifndef _SSL_ENUM_CRLS_METHODDEF
#define _SSL_ENUM_CRLS_METHODDEF
#endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */
/*[clinic end generated code: output=f15635b2faa3b2db input=a9049054013a1b77]*/
/*[clinic end generated code: output=aa6b0a898b6077fe input=a9049054013a1b77]*/

View File

@ -94,10 +94,6 @@ Struct_unpack(PyStructObject *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("unpack", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = Struct_unpack_impl(self, &buffer);
exit:
@ -170,10 +166,6 @@ Struct_unpack_from(PyStructObject *self, PyObject *const *args, Py_ssize_t nargs
if (PyObject_GetBuffer(args[0], &buffer, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("unpack_from", "argument 'buffer'", "contiguous buffer", args[0]);
goto exit;
}
if (!noptargs) {
goto skip_optional_pos;
}
@ -300,10 +292,6 @@ unpack(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("unpack", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
return_value = unpack_impl(module, s_object, &buffer);
exit:
@ -379,10 +367,6 @@ unpack_from(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("unpack_from", "argument 'buffer'", "contiguous buffer", args[1]);
goto exit;
}
if (!noptargs) {
goto skip_optional_pos;
}
@ -452,4 +436,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=1749aaf639d5c11c input=a9049054013a1b77]*/
/*[clinic end generated code: output=6a20e87f9b298b14 input=a9049054013a1b77]*/

View File

@ -442,10 +442,6 @@ array_array_frombytes(arrayobject *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("frombytes", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = array_array_frombytes_impl(self, &buffer);
exit:
@ -671,4 +667,4 @@ PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
{"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
/*[clinic end generated code: output=d58693e1157540ef input=a9049054013a1b77]*/
/*[clinic end generated code: output=bf086c01e7e482bf input=a9049054013a1b77]*/

View File

@ -92,10 +92,6 @@ binascii_b2a_uu(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("b2a_uu", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (!noptargs) {
goto skip_optional_kwonly;
}
@ -243,10 +239,6 @@ binascii_b2a_base64(PyObject *module, PyObject *const *args, Py_ssize_t nargs, P
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("b2a_base64", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (!noptargs) {
goto skip_optional_kwonly;
}
@ -291,10 +283,6 @@ binascii_crc_hqx(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("crc_hqx", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
crc = (unsigned int)PyLong_AsUnsignedLongMask(args[1]);
if (crc == (unsigned int)-1 && PyErr_Occurred()) {
goto exit;
@ -336,10 +324,6 @@ binascii_crc32(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("crc32", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -435,10 +419,6 @@ binascii_b2a_hex(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("b2a_hex", "argument 'data'", "contiguous buffer", args[0]);
goto exit;
}
if (!noptargs) {
goto skip_optional_pos;
}
@ -528,10 +508,6 @@ binascii_hexlify(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("hexlify", "argument 'data'", "contiguous buffer", args[0]);
goto exit;
}
if (!noptargs) {
goto skip_optional_pos;
}
@ -755,10 +731,6 @@ binascii_b2a_qp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("b2a_qp", "argument 'data'", "contiguous buffer", args[0]);
goto exit;
}
if (!noptargs) {
goto skip_optional_pos;
}
@ -795,4 +767,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=3259f3b018abee96 input=a9049054013a1b77]*/
/*[clinic end generated code: output=968767b663ed889d input=a9049054013a1b77]*/

View File

@ -624,10 +624,6 @@ _overlapped_Overlapped_ReadFileInto(OverlappedObject *self, PyObject *const *arg
if (PyObject_GetBuffer(args[1], &bufobj, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&bufobj, 'C')) {
_PyArg_BadArgument("ReadFileInto", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
return_value = _overlapped_Overlapped_ReadFileInto_impl(self, handle, &bufobj);
exit:
@ -715,10 +711,6 @@ _overlapped_Overlapped_WSARecvInto(OverlappedObject *self, PyObject *const *args
if (PyObject_GetBuffer(args[1], &bufobj, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&bufobj, 'C')) {
_PyArg_BadArgument("WSARecvInto", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
if (!_PyLong_UnsignedLong_Converter(args[2], &flags)) {
goto exit;
}
@ -763,10 +755,6 @@ _overlapped_Overlapped_WriteFile(OverlappedObject *self, PyObject *const *args,
if (PyObject_GetBuffer(args[1], &bufobj, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&bufobj, 'C')) {
_PyArg_BadArgument("WriteFile", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
return_value = _overlapped_Overlapped_WriteFile_impl(self, handle, &bufobj);
exit:
@ -809,10 +797,6 @@ _overlapped_Overlapped_WSASend(OverlappedObject *self, PyObject *const *args, Py
if (PyObject_GetBuffer(args[1], &bufobj, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&bufobj, 'C')) {
_PyArg_BadArgument("WSASend", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
if (!_PyLong_UnsignedLong_Converter(args[2], &flags)) {
goto exit;
}
@ -1138,10 +1122,6 @@ _overlapped_Overlapped_WSASendTo(OverlappedObject *self, PyObject *const *args,
if (PyObject_GetBuffer(args[1], &bufobj, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&bufobj, 'C')) {
_PyArg_BadArgument("WSASendTo", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
if (!_PyLong_UnsignedLong_Converter(args[2], &flags)) {
goto exit;
}
@ -1239,10 +1219,6 @@ _overlapped_Overlapped_WSARecvFromInto(OverlappedObject *self, PyObject *const *
if (PyObject_GetBuffer(args[1], &bufobj, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&bufobj, 'C')) {
_PyArg_BadArgument("WSARecvFromInto", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
if (!_PyLong_UnsignedLong_Converter(args[2], &size)) {
goto exit;
}
@ -1263,4 +1239,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=85884c2341fcbef7 input=a9049054013a1b77]*/
/*[clinic end generated code: output=958cbddbcc355f47 input=a9049054013a1b77]*/

View File

@ -7208,10 +7208,6 @@ os_write(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[1], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("write", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
_return_value = os_write_impl(module, fd, &data);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
@ -7810,10 +7806,6 @@ os_pwrite(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("pwrite", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
if (!Py_off_t_converter(args[2], &offset)) {
goto exit;
}
@ -10252,10 +10244,6 @@ os_setxattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
if (PyObject_GetBuffer(args[2], &value, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&value, 'C')) {
_PyArg_BadArgument("setxattr", "argument 'value'", "contiguous buffer", args[2]);
goto exit;
}
if (!noptargs) {
goto skip_optional_pos;
}
@ -12415,4 +12403,4 @@ exit:
#ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF
#define OS_WAITSTATUS_TO_EXITCODE_METHODDEF
#endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */
/*[clinic end generated code: output=274174066fff3256 input=a9049054013a1b77]*/
/*[clinic end generated code: output=a05abdc48e3def44 input=a9049054013a1b77]*/

View File

@ -70,10 +70,6 @@ zlib_compress(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("compress", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (!noptargs) {
goto skip_optional_pos;
}
@ -164,10 +160,6 @@ zlib_decompress(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("decompress", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (!noptargs) {
goto skip_optional_pos;
}
@ -334,10 +326,6 @@ zlib_compressobj(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb
if (PyObject_GetBuffer(args[5], &zdict, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&zdict, 'C')) {
_PyArg_BadArgument("compressobj", "argument 'zdict'", "contiguous buffer", args[5]);
goto exit;
}
skip_optional_pos:
return_value = zlib_compressobj_impl(module, level, method, wbits, memLevel, strategy, &zdict);
@ -473,10 +461,6 @@ zlib_Compress_compress(compobject *self, PyTypeObject *cls, PyObject *const *arg
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("compress", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
return_value = zlib_Compress_compress_impl(self, cls, &data);
exit:
@ -553,10 +537,6 @@ zlib_Decompress_decompress(compobject *self, PyTypeObject *cls, PyObject *const
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("decompress", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (!noptargs) {
goto skip_optional_pos;
}
@ -965,10 +945,6 @@ zlib_ZlibDecompressor_decompress(ZlibDecompressor *self, PyObject *const *args,
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("decompress", "argument 'data'", "contiguous buffer", args[0]);
goto exit;
}
if (!noptargs) {
goto skip_optional_pos;
}
@ -1026,10 +1002,6 @@ zlib_adler32(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("adler32", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -1080,10 +1052,6 @@ zlib_crc32(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("crc32", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
@ -1130,4 +1098,4 @@ exit:
#ifndef ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
#define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
#endif /* !defined(ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF) */
/*[clinic end generated code: output=bd96ba786b0d8d42 input=a9049054013a1b77]*/
/*[clinic end generated code: output=6dd97dc851c39031 input=a9049054013a1b77]*/

View File

@ -162,10 +162,6 @@ bytearray_removeprefix(PyByteArrayObject *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &prefix, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&prefix, 'C')) {
_PyArg_BadArgument("removeprefix", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = bytearray_removeprefix_impl(self, &prefix);
exit:
@ -202,10 +198,6 @@ bytearray_removesuffix(PyByteArrayObject *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &suffix, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&suffix, 'C')) {
_PyArg_BadArgument("removesuffix", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = bytearray_removesuffix_impl(self, &suffix);
exit:
@ -316,17 +308,9 @@ bytearray_maketrans(void *null, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[0], &frm, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&frm, 'C')) {
_PyArg_BadArgument("maketrans", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (PyObject_GetBuffer(args[1], &to, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&to, 'C')) {
_PyArg_BadArgument("maketrans", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
return_value = bytearray_maketrans_impl(&frm, &to);
exit:
@ -376,17 +360,9 @@ bytearray_replace(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nar
if (PyObject_GetBuffer(args[0], &old, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&old, 'C')) {
_PyArg_BadArgument("replace", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (PyObject_GetBuffer(args[1], &new, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&new, 'C')) {
_PyArg_BadArgument("replace", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
if (nargs < 3) {
goto skip_optional;
}
@ -1285,4 +1261,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
{
return bytearray_sizeof_impl(self);
}
/*[clinic end generated code: output=fc2b9ccabe0e6782 input=a9049054013a1b77]*/
/*[clinic end generated code: output=0797a5e03cda2a16 input=a9049054013a1b77]*/

View File

@ -141,10 +141,6 @@ bytes_partition(PyBytesObject *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &sep, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&sep, 'C')) {
_PyArg_BadArgument("partition", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = bytes_partition_impl(self, &sep);
exit:
@ -184,10 +180,6 @@ bytes_rpartition(PyBytesObject *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &sep, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&sep, 'C')) {
_PyArg_BadArgument("rpartition", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = bytes_rpartition_impl(self, &sep);
exit:
@ -503,17 +495,9 @@ bytes_maketrans(void *null, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[0], &frm, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&frm, 'C')) {
_PyArg_BadArgument("maketrans", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (PyObject_GetBuffer(args[1], &to, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&to, 'C')) {
_PyArg_BadArgument("maketrans", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
return_value = bytes_maketrans_impl(&frm, &to);
exit:
@ -563,17 +547,9 @@ bytes_replace(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs)
if (PyObject_GetBuffer(args[0], &old, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&old, 'C')) {
_PyArg_BadArgument("replace", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
if (PyObject_GetBuffer(args[1], &new, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&new, 'C')) {
_PyArg_BadArgument("replace", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
if (nargs < 3) {
goto skip_optional;
}
@ -629,10 +605,6 @@ bytes_removeprefix(PyBytesObject *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &prefix, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&prefix, 'C')) {
_PyArg_BadArgument("removeprefix", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = bytes_removeprefix_impl(self, &prefix);
exit:
@ -669,10 +641,6 @@ bytes_removesuffix(PyBytesObject *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &suffix, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&suffix, 'C')) {
_PyArg_BadArgument("removesuffix", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = bytes_removesuffix_impl(self, &suffix);
exit:
@ -1061,4 +1029,4 @@ skip_optional_pos:
exit:
return return_value;
}
/*[clinic end generated code: output=da013a7e257f5c6e input=a9049054013a1b77]*/
/*[clinic end generated code: output=8a49dbbd78914a6f input=a9049054013a1b77]*/

View File

@ -605,10 +605,6 @@ _imp_source_hash(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb
if (PyObject_GetBuffer(args[1], &source, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&source, 'C')) {
_PyArg_BadArgument("source_hash", "argument 'source'", "contiguous buffer", args[1]);
goto exit;
}
return_value = _imp_source_hash_impl(module, key, &source);
exit:
@ -627,4 +623,4 @@ exit:
#ifndef _IMP_EXEC_DYNAMIC_METHODDEF
#define _IMP_EXEC_DYNAMIC_METHODDEF
#endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */
/*[clinic end generated code: output=c37ad1bf06f9e947 input=a9049054013a1b77]*/
/*[clinic end generated code: output=dbd63707bd40b07c input=a9049054013a1b77]*/

View File

@ -143,10 +143,6 @@ marshal_loads(PyObject *module, PyObject *arg)
if (PyObject_GetBuffer(arg, &bytes, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&bytes, 'C')) {
_PyArg_BadArgument("loads", "argument", "contiguous buffer", arg);
goto exit;
}
return_value = marshal_loads_impl(module, &bytes);
exit:
@ -157,4 +153,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=99ba446b1a75a269 input=a9049054013a1b77]*/
/*[clinic end generated code: output=92d2d47aac9128ee input=a9049054013a1b77]*/

View File

@ -1187,17 +1187,15 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
arg, msgbuf, bufsize);
format++;
/* Caller is interested in Py_buffer, and the object
supports it directly. */
/* Caller is interested in Py_buffer, and the object supports it
directly. The request implicitly asks for PyBUF_SIMPLE, so the
result is C-contiguous with format 'B'. */
if (PyObject_GetBuffer(arg, (Py_buffer*)p, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
return converterr("read-write bytes-like object",
arg, msgbuf, bufsize);
}
if (!PyBuffer_IsContiguous((Py_buffer*)p, 'C')) {
PyBuffer_Release((Py_buffer*)p);
return converterr("contiguous buffer", arg, msgbuf, bufsize);
}
assert(PyBuffer_IsContiguous((Py_buffer *)p, 'C'));
if (addcleanup(p, freelist, cleanup_buffer)) {
return converterr(
"(cleanup problem)",
@ -1242,15 +1240,12 @@ convertbuffer(PyObject *arg, const void **p, const char **errmsg)
static int
getbuffer(PyObject *arg, Py_buffer *view, const char **errmsg)
{
/* PyBUF_SIMPLE implies C-contiguous */
if (PyObject_GetBuffer(arg, view, PyBUF_SIMPLE) != 0) {
*errmsg = "bytes-like object";
return -1;
}
if (!PyBuffer_IsContiguous(view, 'C')) {
PyBuffer_Release(view);
*errmsg = "contiguous buffer";
return -1;
}
assert(PyBuffer_IsContiguous(view, 'C'));
return 0;
}

View File

@ -4605,15 +4605,12 @@ class Py_buffer_converter(CConverter):
return "".join(["if (", name, ".obj) {\n PyBuffer_Release(&", name, ");\n}\n"])
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None:
# PyBUF_SIMPLE guarantees that the format units of the buffers are C-contiguous.
if self.format_unit == 'y*':
return self.format_code("""
if (PyObject_GetBuffer({argname}, &{paramname}, PyBUF_SIMPLE) != 0) {{{{
goto exit;
}}}}
if (!PyBuffer_IsContiguous(&{paramname}, 'C')) {{{{
{bad_argument}
goto exit;
}}}}
""",
argname=argname,
bad_argument=self.bad_argument(displayname, 'contiguous buffer', limited_capi=limited_capi),
@ -4632,10 +4629,6 @@ class Py_buffer_converter(CConverter):
if (PyObject_GetBuffer({argname}, &{paramname}, PyBUF_SIMPLE) != 0) {{{{
goto exit;
}}}}
if (!PyBuffer_IsContiguous(&{paramname}, 'C')) {{{{
{bad_argument}
goto exit;
}}}}
}}}}
""",
argname=argname,
@ -4647,10 +4640,6 @@ class Py_buffer_converter(CConverter):
{bad_argument}
goto exit;
}}}}
if (!PyBuffer_IsContiguous(&{paramname}, 'C')) {{{{
{bad_argument2}
goto exit;
}}}}
""",
argname=argname,
bad_argument=self.bad_argument(displayname, 'read-write bytes-like object', limited_capi=limited_capi),