From 7cf8bebb07914408f71f6c0e0e1cf0a2eafa72d3 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 21 Jan 2017 23:05:00 +0200 Subject: Issue #29331: Simplified argument parsing in sorted() and list.sort(). --- Python/bltinmodule.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'Python/bltinmodule.c') diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 6df8af4733..3473cc322c 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); -- cgit v1.2.1