https://github.com/python/cpython/commit/87cd20a567aca56369010689e22a524bc1f1ac03
commit: 87cd20a567aca56369010689e22a524bc1f1ac03
branch: main
author: Nikita Sobolev <[email protected]>
committer: erlend-aasland <[email protected]>
date: 2024-02-05T11:45:09+01:00
summary:
gh-115026: Argument Clinic: handle PyBuffer_FillInfo errors in generated code
(#115027)
files:
M Modules/_sqlite/clinic/connection.c.h
M Modules/clinic/_codecsmodule.c.h
M Modules/clinic/_ssl.c.h
M Tools/clinic/clinic.py
diff --git a/Modules/_sqlite/clinic/connection.c.h
b/Modules/_sqlite/clinic/connection.c.h
index db5eb77891e52e..f2cff6a7b421f3 100644
--- a/Modules/_sqlite/clinic/connection.c.h
+++ b/Modules/_sqlite/clinic/connection.c.h
@@ -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 @@ getconfig(pysqlite_Connection *self, PyObject *arg)
#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]*/
diff --git a/Modules/clinic/_codecsmodule.c.h b/Modules/clinic/_codecsmodule.c.h
index 12fea806ab5209..1c0f37442ab350 100644
--- a/Modules/clinic/_codecsmodule.c.h
+++ b/Modules/clinic/_codecsmodule.c.h
@@ -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 @@ _codecs_lookup_error(PyObject *module, PyObject *arg)
#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]*/
diff --git a/Modules/clinic/_ssl.c.h b/Modules/clinic/_ssl.c.h
index 19c0f619b92f45..2940f16a2cb7f6 100644
--- a/Modules/clinic/_ssl.c.h
+++ b/Modules/clinic/_ssl.c.h
@@ -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 @@ _ssl_enum_crls(PyObject *module, PyObject *const *args,
Py_ssize_t nargs, PyObje
#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]*/
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 770878a3f8d2c7..c1df83a72bd8ce 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -4368,7 +4368,9 @@ def parse_arg(self, argname: str, displayname: str, *,
limited_capi: bool) -> st
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) {{{{
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]