mirror of https://github.com/python/cpython
gh-115026: Argument Clinic: handle PyBuffer_FillInfo errors in generated code (#115027)
This commit is contained in:
parent
f71bdd3408
commit
87cd20a567
|
@ -1551,7 +1551,9 @@ deserialize(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs,
|
|||
if (ptr == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0);
|
||||
if (PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, PyBUF_SIMPLE) < 0) {
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else { /* any bytes-like object */
|
||||
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
|
||||
|
@ -1818,4 +1820,4 @@ exit:
|
|||
#ifndef DESERIALIZE_METHODDEF
|
||||
#define DESERIALIZE_METHODDEF
|
||||
#endif /* !defined(DESERIALIZE_METHODDEF) */
|
||||
/*[clinic end generated code: output=90b5b9c14261b8d7 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=99299d3ee2c247ab input=a9049054013a1b77]*/
|
||||
|
|
|
@ -297,7 +297,9 @@ _codecs_escape_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
|
|||
if (ptr == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0);
|
||||
if (PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, PyBUF_SIMPLE) < 0) {
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else { /* any bytes-like object */
|
||||
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
|
||||
|
@ -1099,7 +1101,9 @@ _codecs_unicode_escape_decode(PyObject *module, PyObject *const *args, Py_ssize_
|
|||
if (ptr == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0);
|
||||
if (PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, PyBUF_SIMPLE) < 0) {
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else { /* any bytes-like object */
|
||||
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
|
||||
|
@ -1175,7 +1179,9 @@ _codecs_raw_unicode_escape_decode(PyObject *module, PyObject *const *args, Py_ss
|
|||
if (ptr == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0);
|
||||
if (PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, PyBUF_SIMPLE) < 0) {
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else { /* any bytes-like object */
|
||||
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
|
||||
|
@ -1644,7 +1650,9 @@ _codecs_readbuffer_encode(PyObject *module, PyObject *const *args, Py_ssize_t na
|
|||
if (ptr == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0);
|
||||
if (PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, PyBUF_SIMPLE) < 0) {
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else { /* any bytes-like object */
|
||||
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
|
||||
|
@ -2738,4 +2746,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=d8d9e372f7ccba35 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=e50d5fdf65bd45fa input=a9049054013a1b77]*/
|
||||
|
|
|
@ -1297,7 +1297,9 @@ _ssl_RAND_add(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
|
|||
if (ptr == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
PyBuffer_FillInfo(&view, args[0], (void *)ptr, len, 1, 0);
|
||||
if (PyBuffer_FillInfo(&view, args[0], (void *)ptr, len, 1, PyBUF_SIMPLE) < 0) {
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else { /* any bytes-like object */
|
||||
if (PyObject_GetBuffer(args[0], &view, PyBUF_SIMPLE) != 0) {
|
||||
|
@ -1662,4 +1664,4 @@ exit:
|
|||
#ifndef _SSL_ENUM_CRLS_METHODDEF
|
||||
#define _SSL_ENUM_CRLS_METHODDEF
|
||||
#endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */
|
||||
/*[clinic end generated code: output=6342ea0062ab16c7 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=fd1c3378fbba5240 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -4368,7 +4368,9 @@ class Py_buffer_converter(CConverter):
|
|||
if (ptr == NULL) {{{{
|
||||
goto exit;
|
||||
}}}}
|
||||
PyBuffer_FillInfo(&{paramname}, {argname}, (void *)ptr, len, 1, 0);
|
||||
if (PyBuffer_FillInfo(&{paramname}, {argname}, (void *)ptr, len, 1, PyBUF_SIMPLE) < 0) {{{{
|
||||
goto exit;
|
||||
}}}}
|
||||
}}}}
|
||||
else {{{{ /* any bytes-like object */
|
||||
if (PyObject_GetBuffer({argname}, &{paramname}, PyBUF_SIMPLE) != 0) {{{{
|
||||
|
|
Loading…
Reference in New Issue