diff options
author | Sylvain <sylvain.desodt+github@gmail.com> | 2017-06-10 06:51:48 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-06-10 07:51:48 +0300 |
commit | 7445381c606faf20e253da42656db478a4349f8e (patch) | |
tree | 49ad79e5347454d1bbfeb1c2d06d3d09fd9b273f /Python/clinic | |
parent | bpo-25409: Clarify fnmatch and fnmatchcase documentation (GH-1535) (diff) | |
download | cpython-7445381c606faf20e253da42656db478a4349f8e.tar.gz cpython-7445381c606faf20e253da42656db478a4349f8e.tar.bz2 cpython-7445381c606faf20e253da42656db478a4349f8e.zip |
bpo-30600: Fix error messages (condition order in Argument Clinic) (#2051)
The function '_PyArg_ParseStack()' and
'_PyArg_UnpackStack' were failing (with error
"XXX() takes Y argument (Z given)") before
the function '_PyArg_NoStackKeywords()' was called.
Thus, the latter did not raise its more meaningful
error : "XXX() takes no keyword arguments".
Diffstat (limited to 'Python/clinic')
-rw-r--r-- | Python/clinic/bltinmodule.c.h | 96 | ||||
-rw-r--r-- | Python/clinic/import.c.h | 16 | ||||
-rw-r--r-- | Python/clinic/marshal.c.h | 14 |
3 files changed, 63 insertions, 63 deletions
diff --git a/Python/clinic/bltinmodule.c.h b/Python/clinic/bltinmodule.c.h index d93a45d1b80..0e46f94feac 100644 --- a/Python/clinic/bltinmodule.c.h +++ b/Python/clinic/bltinmodule.c.h @@ -94,12 +94,12 @@ builtin_format(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kw PyObject *value; PyObject *format_spec = NULL; - if (!_PyArg_ParseStack(args, nargs, "O|U:format", - &value, &format_spec)) { + if (!_PyArg_NoStackKeywords("format", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("format", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "O|U:format", + &value, &format_spec)) { goto exit; } return_value = builtin_format_impl(module, value, format_spec); @@ -203,13 +203,13 @@ builtin_divmod(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kw PyObject *x; PyObject *y; - if (!_PyArg_UnpackStack(args, nargs, "divmod", - 2, 2, - &x, &y)) { + if (!_PyArg_NoStackKeywords("divmod", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("divmod", kwnames)) { + if (!_PyArg_UnpackStack(args, nargs, "divmod", + 2, 2, + &x, &y)) { goto exit; } return_value = builtin_divmod_impl(module, x, y); @@ -245,13 +245,13 @@ builtin_eval(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwna PyObject *globals = Py_None; PyObject *locals = Py_None; - if (!_PyArg_UnpackStack(args, nargs, "eval", - 1, 3, - &source, &globals, &locals)) { + if (!_PyArg_NoStackKeywords("eval", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("eval", kwnames)) { + if (!_PyArg_UnpackStack(args, nargs, "eval", + 1, 3, + &source, &globals, &locals)) { goto exit; } return_value = builtin_eval_impl(module, source, globals, locals); @@ -287,13 +287,13 @@ builtin_exec(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwna PyObject *globals = Py_None; PyObject *locals = Py_None; - if (!_PyArg_UnpackStack(args, nargs, "exec", - 1, 3, - &source, &globals, &locals)) { + if (!_PyArg_NoStackKeywords("exec", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("exec", kwnames)) { + if (!_PyArg_UnpackStack(args, nargs, "exec", + 1, 3, + &source, &globals, &locals)) { goto exit; } return_value = builtin_exec_impl(module, source, globals, locals); @@ -344,13 +344,13 @@ builtin_hasattr(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *k PyObject *obj; PyObject *name; - if (!_PyArg_UnpackStack(args, nargs, "hasattr", - 2, 2, - &obj, &name)) { + if (!_PyArg_NoStackKeywords("hasattr", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("hasattr", kwnames)) { + if (!_PyArg_UnpackStack(args, nargs, "hasattr", + 2, 2, + &obj, &name)) { goto exit; } return_value = builtin_hasattr_impl(module, obj, name); @@ -394,13 +394,13 @@ builtin_setattr(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *k PyObject *name; PyObject *value; - if (!_PyArg_UnpackStack(args, nargs, "setattr", - 3, 3, - &obj, &name, &value)) { + if (!_PyArg_NoStackKeywords("setattr", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("setattr", kwnames)) { + if (!_PyArg_UnpackStack(args, nargs, "setattr", + 3, 3, + &obj, &name, &value)) { goto exit; } return_value = builtin_setattr_impl(module, obj, name, value); @@ -430,13 +430,13 @@ builtin_delattr(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *k PyObject *obj; PyObject *name; - if (!_PyArg_UnpackStack(args, nargs, "delattr", - 2, 2, - &obj, &name)) { + if (!_PyArg_NoStackKeywords("delattr", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("delattr", kwnames)) { + if (!_PyArg_UnpackStack(args, nargs, "delattr", + 2, 2, + &obj, &name)) { goto exit; } return_value = builtin_delattr_impl(module, obj, name); @@ -544,13 +544,13 @@ builtin_pow(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnam PyObject *y; PyObject *z = Py_None; - if (!_PyArg_UnpackStack(args, nargs, "pow", - 2, 3, - &x, &y, &z)) { + if (!_PyArg_NoStackKeywords("pow", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("pow", kwnames)) { + if (!_PyArg_UnpackStack(args, nargs, "pow", + 2, 3, + &x, &y, &z)) { goto exit; } return_value = builtin_pow_impl(module, x, y, z); @@ -583,13 +583,13 @@ builtin_input(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwn PyObject *return_value = NULL; PyObject *prompt = NULL; - if (!_PyArg_UnpackStack(args, nargs, "input", - 0, 1, - &prompt)) { + if (!_PyArg_NoStackKeywords("input", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("input", kwnames)) { + if (!_PyArg_UnpackStack(args, nargs, "input", + 0, 1, + &prompt)) { goto exit; } return_value = builtin_input_impl(module, prompt); @@ -632,13 +632,13 @@ builtin_sum(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnam PyObject *iterable; PyObject *start = NULL; - if (!_PyArg_UnpackStack(args, nargs, "sum", - 1, 2, - &iterable, &start)) { + if (!_PyArg_NoStackKeywords("sum", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("sum", kwnames)) { + if (!_PyArg_UnpackStack(args, nargs, "sum", + 1, 2, + &iterable, &start)) { goto exit; } return_value = builtin_sum_impl(module, iterable, start); @@ -671,13 +671,13 @@ builtin_isinstance(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject PyObject *obj; PyObject *class_or_tuple; - if (!_PyArg_UnpackStack(args, nargs, "isinstance", - 2, 2, - &obj, &class_or_tuple)) { + if (!_PyArg_NoStackKeywords("isinstance", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("isinstance", kwnames)) { + if (!_PyArg_UnpackStack(args, nargs, "isinstance", + 2, 2, + &obj, &class_or_tuple)) { goto exit; } return_value = builtin_isinstance_impl(module, obj, class_or_tuple); @@ -710,13 +710,13 @@ builtin_issubclass(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject PyObject *cls; PyObject *class_or_tuple; - if (!_PyArg_UnpackStack(args, nargs, "issubclass", - 2, 2, - &cls, &class_or_tuple)) { + if (!_PyArg_NoStackKeywords("issubclass", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("issubclass", kwnames)) { + if (!_PyArg_UnpackStack(args, nargs, "issubclass", + 2, 2, + &cls, &class_or_tuple)) { goto exit; } return_value = builtin_issubclass_impl(module, cls, class_or_tuple); @@ -724,4 +724,4 @@ builtin_issubclass(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject exit: return return_value; } -/*[clinic end generated code: output=17fedd2dec148677 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e1a7417a7b33eeec input=a9049054013a1b77]*/ diff --git a/Python/clinic/import.c.h b/Python/clinic/import.c.h index 0165b7c4e19..5f4bad262c8 100644 --- a/Python/clinic/import.c.h +++ b/Python/clinic/import.c.h @@ -88,12 +88,12 @@ _imp__fix_co_filename(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObj PyCodeObject *code; PyObject *path; - if (!_PyArg_ParseStack(args, nargs, "O!U:_fix_co_filename", - &PyCode_Type, &code, &path)) { + if (!_PyArg_NoStackKeywords("_fix_co_filename", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("_fix_co_filename", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "O!U:_fix_co_filename", + &PyCode_Type, &code, &path)) { goto exit; } return_value = _imp__fix_co_filename_impl(module, code, path); @@ -285,13 +285,13 @@ _imp_create_dynamic(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObjec PyObject *spec; PyObject *file = NULL; - if (!_PyArg_UnpackStack(args, nargs, "create_dynamic", - 1, 2, - &spec, &file)) { + if (!_PyArg_NoStackKeywords("create_dynamic", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("create_dynamic", kwnames)) { + if (!_PyArg_UnpackStack(args, nargs, "create_dynamic", + 1, 2, + &spec, &file)) { goto exit; } return_value = _imp_create_dynamic_impl(module, spec, file); @@ -369,4 +369,4 @@ exit: #ifndef _IMP_EXEC_DYNAMIC_METHODDEF #define _IMP_EXEC_DYNAMIC_METHODDEF #endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */ -/*[clinic end generated code: output=c1d0e65d04114958 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b970357dbbe25ee4 input=a9049054013a1b77]*/ diff --git a/Python/clinic/marshal.c.h b/Python/clinic/marshal.c.h index ae2c8990a6c..64504ba826c 100644 --- a/Python/clinic/marshal.c.h +++ b/Python/clinic/marshal.c.h @@ -34,12 +34,12 @@ marshal_dump(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwna PyObject *file; int version = Py_MARSHAL_VERSION; - if (!_PyArg_ParseStack(args, nargs, "OO|i:dump", - &value, &file, &version)) { + if (!_PyArg_NoStackKeywords("dump", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("dump", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "OO|i:dump", + &value, &file, &version)) { goto exit; } return_value = marshal_dump_impl(module, value, file, version); @@ -94,12 +94,12 @@ marshal_dumps(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwn PyObject *value; int version = Py_MARSHAL_VERSION; - if (!_PyArg_ParseStack(args, nargs, "O|i:dumps", - &value, &version)) { + if (!_PyArg_NoStackKeywords("dumps", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("dumps", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "O|i:dumps", + &value, &version)) { goto exit; } return_value = marshal_dumps_impl(module, value, version); @@ -142,4 +142,4 @@ exit: return return_value; } -/*[clinic end generated code: output=9dec2158b8c5d975 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7b147a648614af7e input=a9049054013a1b77]*/ |