| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1627,6 +1627,16 @@ def test_basic(self): | |||
| 1627 | 1627 | self.assertEqual(data, sorted(copy, reverse=1)) | |
| 1628 | 1628 | self.assertNotEqual(data, copy) | |
| 1629 | 1629 | ||
| 1630 | + def test_bad_arguments(self): | ||
| 1631 | + # Issue #29327: The first argument is positional-only. | ||
| 1632 | + sorted([]) | ||
| 1633 | + with self.assertRaises(TypeError): | ||
| 1634 | + sorted(iterable=[]) | ||
| 1635 | + # Other arguments are keyword-only | ||
| 1636 | + sorted([], key=None) | ||
| 1637 | + with self.assertRaises(TypeError): | ||
| 1638 | + sorted([], None) | ||
| 1639 | + | ||
| 1630 | 1640 | def test_inputtypes(self): | |
| 1631 | 1641 | s = 'abracadabra' | |
| 1632 | 1642 | types = [list, tuple, str] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,9 @@ What's New in Python 3.7.0 alpha 1? | |||
| 10 | 10 | Core and Builtins | |
| 11 | 11 | ----------------- | |
| 12 | 12 | ||
| 13 | + - Issue #29327: Fixed a crash when pass the iterable keyword argument to | ||
| 14 | + sorted(). | ||
| 15 | + | ||
| 13 | 16 | - Issue #29034: Fix memory leak and use-after-free in os module (path_converter). | |
| 14 | 17 | ||
| 15 | 18 | - Issue #29159: Fix regression in bytes(x) when x.__index__() raises Exception. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2128,7 +2128,7 @@ builtin_sorted(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwna | |||
| 2128 | 2128 | { | |
| 2129 | 2129 | PyObject *newlist, *v, *seq, *keyfunc=NULL; | |
| 2130 | 2130 | PyObject *callable; | |
| 2131 | - static const char * const kwlist[] = {"iterable", "key", "reverse", 0}; | ||
| 2131 | + static const char * const kwlist[] = {"", "key", "reverse", 0}; | ||
| 2132 | 2132 | /* args 1-3 should match listsort in Objects/listobject.c */ | |
| 2133 | 2133 | static _PyArg_Parser parser = {"O|Oi:sorted", kwlist, 0}; | |
| 2134 | 2134 | int reverse; | |
@@ -2147,6 +2147,7 @@ builtin_sorted(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwna | |||
| 2147 | 2147 | return NULL; | |
| 2148 | 2148 | } | |
| 2149 | 2149 | ||
| 2150 | + assert(nargs >= 1); | ||
| 2150 | 2151 | v = _PyObject_FastCallKeywords(callable, args + 1, nargs - 1, kwnames); | |
| 2151 | 2152 | Py_DECREF(callable); | |
| 2152 | 2153 | if (v == NULL) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments