diff options
author | Larry Hastings <larry@hastings.org> | 2014-01-19 07:50:21 (GMT) |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2014-01-19 07:50:21 (GMT) |
commit | b7ccb204236dca49f3d8d119aa84631f519add09 (patch) | |
tree | 18699632f81936d27c4a4edd1d5346804f5fb466 /Python | |
parent | b470575e2492349584d9afa2a9d581b58ee92c38 (diff) | |
download | cpython-b7ccb204236dca49f3d8d119aa84631f519add09.zip cpython-b7ccb204236dca49f3d8d119aa84631f519add09.tar.gz cpython-b7ccb204236dca49f3d8d119aa84631f519add09.tar.bz2 |
Issue #20294: Argument Clinic now supports argument parsing for __new__ and
__init__ functions.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/getargs.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/Python/getargs.c b/Python/getargs.c index 6084568..bfea111 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -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 |