bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)

This commit is contained in:
Serhiy Storchaka 2018-12-25 13:23:47 +02:00 • committed by GitHub
parent 65ce60aef1
commit 32d96a2b5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 1677 additions and 275 deletions

View file

@ -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]*/