diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-12-25 11:23:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-25 11:23:47 (GMT) |
commit | 32d96a2b5bc3136d45a66adbdb45fac351b520ce (patch) | |
tree | acf51c9945f764ab103597c9cba376f154aa600d /Modules/clinic/_struct.c.h | |
parent | 65ce60aef150776f884715b4315a10a0d6ae769e (diff) | |
download | cpython-32d96a2b5bc3136d45a66adbdb45fac351b520ce.zip cpython-32d96a2b5bc3136d45a66adbdb45fac351b520ce.tar.gz cpython-32d96a2b5bc3136d45a66adbdb45fac351b520ce.tar.bz2 |
bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)
Diffstat (limited to 'Modules/clinic/_struct.c.h')
-rw-r--r-- | Modules/clinic/_struct.c.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Modules/clinic/_struct.c.h b/Modules/clinic/_struct.c.h index b1fa067..3a186e4 100644 --- a/Modules/clinic/_struct.c.h +++ b/Modules/clinic/_struct.c.h @@ -57,7 +57,11 @@ Struct_unpack(PyStructObject *self, PyObject *arg) PyObject *return_value = NULL; Py_buffer buffer = {NULL, NULL}; - if (!PyArg_Parse(arg, "y*:unpack", &buffer)) { + if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&buffer, 'C')) { + _PyArg_BadArgument("unpack", "contiguous buffer", arg); goto exit; } return_value = Struct_unpack_impl(self, &buffer); @@ -166,7 +170,7 @@ calcsize(PyObject *module, PyObject *arg) PyStructObject *s_object = NULL; Py_ssize_t _return_value; - if (!PyArg_Parse(arg, "O&:calcsize", cache_struct_converter, &s_object)) { + if (!cache_struct_converter(arg, &s_object)) { goto exit; } _return_value = calcsize_impl(module, s_object); @@ -303,4 +307,4 @@ exit: return return_value; } -/*[clinic end generated code: output=a73b0453174e4b51 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=01516bea2641fe01 input=a9049054013a1b77]*/ |