mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
Issue #29327: Fixed a crash when pass the iterable keyword argument to sorted().
This commit is contained in:
parent
a57a8a3e2d
commit
398ef5c08f
3 changed files with 15 additions and 1 deletions
|
@ -1627,6 +1627,16 @@ class TestSorted(unittest.TestCase):
|
||||||
self.assertEqual(data, sorted(copy, reverse=1))
|
self.assertEqual(data, sorted(copy, reverse=1))
|
||||||
self.assertNotEqual(data, copy)
|
self.assertNotEqual(data, copy)
|
||||||
|
|
||||||
|
def test_bad_arguments(self):
|
||||||
|
# Issue #29327: The first argument is positional-only.
|
||||||
|
sorted([])
|
||||||
|
with self.assertRaises(TypeError):
|
||||||
|
sorted(iterable=[])
|
||||||
|
# Other arguments are keyword-only
|
||||||
|
sorted([], key=None)
|
||||||
|
with self.assertRaises(TypeError):
|
||||||
|
sorted([], None)
|
||||||
|
|
||||||
def test_inputtypes(self):
|
def test_inputtypes(self):
|
||||||
s = 'abracadabra'
|
s = 'abracadabra'
|
||||||
types = [list, tuple, str]
|
types = [list, tuple, str]
|
||||||
|
|
|
@ -10,6 +10,9 @@ What's New in Python 3.6.1 release candidate 1?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #29327: Fixed a crash when pass the iterable keyword argument to
|
||||||
|
sorted().
|
||||||
|
|
||||||
- Issue #29034: Fix memory leak and use-after-free in os module (path_converter).
|
- Issue #29034: Fix memory leak and use-after-free in os module (path_converter).
|
||||||
|
|
||||||
- Issue #29159: Fix regression in bytes(x) when x.__index__() raises Exception.
|
- Issue #29159: Fix regression in bytes(x) when x.__index__() raises Exception.
|
||||||
|
|
|
@ -2123,7 +2123,7 @@ builtin_sorted(PyObject *self, PyObject *args, PyObject *kwds)
|
||||||
{
|
{
|
||||||
PyObject *newlist, *v, *seq, *keyfunc=NULL, **newargs;
|
PyObject *newlist, *v, *seq, *keyfunc=NULL, **newargs;
|
||||||
PyObject *callable;
|
PyObject *callable;
|
||||||
static char *kwlist[] = {"iterable", "key", "reverse", 0};
|
static char *kwlist[] = {"", "key", "reverse", 0};
|
||||||
int reverse;
|
int reverse;
|
||||||
Py_ssize_t nargs;
|
Py_ssize_t nargs;
|
||||||
|
|
||||||
|
@ -2142,6 +2142,7 @@ builtin_sorted(PyObject *self, PyObject *args, PyObject *kwds)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(PyTuple_GET_SIZE(args) >= 1);
|
||||||
newargs = &PyTuple_GET_ITEM(args, 1);
|
newargs = &PyTuple_GET_ITEM(args, 1);
|
||||||
nargs = PyTuple_GET_SIZE(args) - 1;
|
nargs = PyTuple_GET_SIZE(args) - 1;
|
||||||
v = _PyObject_FastCallDict(callable, newargs, nargs, kwds);
|
v = _PyObject_FastCallDict(callable, newargs, nargs, kwds);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue