diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-01-21 21:05:00 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-01-21 21:05:00 (GMT) |
commit | 7cf8bebb07914408f71f6c0e0e1cf0a2eafa72d3 (patch) | |
tree | 8bcedccf9de27abae490469b6e991b3e73180e86 /Python | |
parent | 5e65cd39dfe73891b16d9c771892e1bc282c1eb9 (diff) | |
download | cpython-7cf8bebb07914408f71f6c0e0e1cf0a2eafa72d3.zip cpython-7cf8bebb07914408f71f6c0e0e1cf0a2eafa72d3.tar.gz cpython-7cf8bebb07914408f71f6c0e0e1cf0a2eafa72d3.tar.bz2 |
Issue #29331: Simplified argument parsing in sorted() and list.sort().
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bltinmodule.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 6df8af4..3473cc3 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -2126,15 +2126,11 @@ PyDoc_STRVAR(builtin_sorted__doc__, static PyObject * builtin_sorted(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { - PyObject *newlist, *v, *seq, *keyfunc=NULL; - PyObject *callable; - static const char * const kwlist[] = {"", "key", "reverse", 0}; - /* args 1-3 should match listsort in Objects/listobject.c */ - static _PyArg_Parser parser = {"O|Oi:sorted", kwlist, 0}; - int reverse; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &parser, - &seq, &keyfunc, &reverse)) + PyObject *newlist, *v, *seq, *callable; + + /* Keyword arguments are passed through list.sort() which will check + them. */ + if (!_PyArg_UnpackStack(args, nargs, "sorted", 1, 1, &seq)) return NULL; newlist = PySequence_List(seq); |