mirror of https://github.com/python/cpython
PyArg_ParseTupleAndKeywords: do basic sanity checks on the arguments,
and raise an error if they're insane. vgetargskeywords: the same, except that since this is an internal routine, just assert that the arguments are sane.
This commit is contained in:
parent
a9f4739a1b
commit
45772cde7e
|
@ -1005,7 +1005,16 @@ PyArg_ParseTupleAndKeywords(PyObject *args,
|
|||
{
|
||||
int retval;
|
||||
va_list va;
|
||||
|
||||
|
||||
if ((args == NULL || !PyTuple_Check(args)) ||
|
||||
(keywords != NULL && !PyDict_Check(keywords)) ||
|
||||
format == NULL ||
|
||||
kwlist == NULL)
|
||||
{
|
||||
PyErr_BadInternalCall();
|
||||
return -1;
|
||||
}
|
||||
|
||||
va_start(va, kwlist);
|
||||
retval = vgetargskeywords(args, keywords, format, kwlist, &va);
|
||||
va_end(va);
|
||||
|
@ -1029,6 +1038,12 @@ vgetargskeywords(PyObject *args, PyObject *keywords, char *format,
|
|||
int nkwds, pos, match, converted;
|
||||
PyObject *key, *value;
|
||||
|
||||
assert(args != NULL && PyTuple_Check(args));
|
||||
assert(keywords == NULL || PyDict_Check(keywords));
|
||||
assert(format != NULL);
|
||||
assert(kwlist != NULL);
|
||||
assert(p_va != NULL);
|
||||
|
||||
/* nested tuples cannot be parsed when using keyword arguments */
|
||||
|
||||
for (;;) {
|
||||
|
|
Loading…
Reference in New Issue