Issue #20294: Argument Clinic now supports argument parsing for __new__ and

__init__ functions.
This commit is contained in:
Larry Hastings 2014-01-18 23:50:21 -08:00
parent b470575e24
commit b7ccb20423
6 changed files with 365 additions and 239 deletions

View file

@ -1805,7 +1805,7 @@ PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t m
/* For type constructors that don't take keyword args
*
* Sets a TypeError and returns 0 if the kwds dict is
* Sets a TypeError and returns 0 if the args/kwargs is
* not empty, returns 1 otherwise
*/
int
@ -1824,6 +1824,25 @@ _PyArg_NoKeywords(const char *funcname, PyObject *kw)
funcname);
return 0;
}
int
_PyArg_NoPositional(const char *funcname, PyObject *args)
{
if (args == NULL)
return 1;
if (!PyTuple_CheckExact(args)) {
PyErr_BadInternalCall();
return 0;
}
if (PyTuple_GET_SIZE(args) == 0)
return 1;
PyErr_Format(PyExc_TypeError, "%s does not take positional arguments",
funcname);
return 0;
}
#ifdef __cplusplus
};
#endif