mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)
This commit is contained in:
10
Python/clinic/bltinmodule.c.h
generated
10
Python/clinic/bltinmodule.c.h
generated
@@ -122,7 +122,13 @@ builtin_chr(PyObject *module, PyObject *arg)
|
||||
PyObject *return_value = NULL;
|
||||
int i;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:chr", &i)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
i = _PyLong_AsInt(arg);
|
||||
if (i == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = builtin_chr_impl(module, i);
|
||||
@@ -711,4 +717,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=fa8d97ac8695363b input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=ed300ebf3f6db530 input=a9049054013a1b77]*/
|
||||
|
||||
37
Python/clinic/import.c.h
generated
37
Python/clinic/import.c.h
generated
@@ -143,9 +143,14 @@ _imp_init_frozen(PyObject *module, PyObject *arg)
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *name;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:init_frozen", &name)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("init_frozen", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
name = arg;
|
||||
return_value = _imp_init_frozen_impl(module, name);
|
||||
|
||||
exit:
|
||||
@@ -170,9 +175,14 @@ _imp_get_frozen_object(PyObject *module, PyObject *arg)
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *name;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:get_frozen_object", &name)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("get_frozen_object", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
name = arg;
|
||||
return_value = _imp_get_frozen_object_impl(module, name);
|
||||
|
||||
exit:
|
||||
@@ -197,9 +207,14 @@ _imp_is_frozen_package(PyObject *module, PyObject *arg)
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *name;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:is_frozen_package", &name)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("is_frozen_package", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
name = arg;
|
||||
return_value = _imp_is_frozen_package_impl(module, name);
|
||||
|
||||
exit:
|
||||
@@ -224,9 +239,14 @@ _imp_is_builtin(PyObject *module, PyObject *arg)
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *name;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:is_builtin", &name)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("is_builtin", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
name = arg;
|
||||
return_value = _imp_is_builtin_impl(module, name);
|
||||
|
||||
exit:
|
||||
@@ -251,9 +271,14 @@ _imp_is_frozen(PyObject *module, PyObject *arg)
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *name;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:is_frozen", &name)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("is_frozen", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
name = arg;
|
||||
return_value = _imp_is_frozen_impl(module, name);
|
||||
|
||||
exit:
|
||||
@@ -396,4 +421,4 @@ exit:
|
||||
#ifndef _IMP_EXEC_DYNAMIC_METHODDEF
|
||||
#define _IMP_EXEC_DYNAMIC_METHODDEF
|
||||
#endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */
|
||||
/*[clinic end generated code: output=ad747b76e105fff2 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=d8be58c9541122f1 input=a9049054013a1b77]*/
|
||||
|
||||
8
Python/clinic/marshal.c.h
generated
8
Python/clinic/marshal.c.h
generated
@@ -121,7 +121,11 @@ marshal_loads(PyObject *module, PyObject *arg)
|
||||
PyObject *return_value = NULL;
|
||||
Py_buffer bytes = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:loads", &bytes)) {
|
||||
if (PyObject_GetBuffer(arg, &bytes, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&bytes, 'C')) {
|
||||
_PyArg_BadArgument("loads", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = marshal_loads_impl(module, &bytes);
|
||||
@@ -134,4 +138,4 @@ exit:
|
||||
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=cbb6128201bee7e0 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=8262e7e6c8cbc1ef input=a9049054013a1b77]*/
|
||||
|
||||
@@ -612,6 +612,14 @@ convertitem(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||
|
||||
/* Format an error message generated by convertsimple(). */
|
||||
|
||||
void
|
||||
_PyArg_BadArgument(const char *fname, const char *expected, PyObject *arg)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError, "%.200s() argument must be %.50s, not %.50s",
|
||||
fname, expected,
|
||||
arg == Py_None ? "None" : arg->ob_type->tp_name);
|
||||
}
|
||||
|
||||
static const char *
|
||||
converterr(const char *expected, PyObject *arg, char *msgbuf, size_t bufsize)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user