mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #20294: Argument Clinic now supports argument parsing for __new__ and
__init__ functions.
This commit is contained in:
parent
b470575e24
commit
b7ccb20423
6 changed files with 365 additions and 239 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue