Issue #29327: Fixed a crash when pass the iterable keyword argument to sorted().

This commit is contained in:
Serhiy Storchaka 2017-01-20 08:35:18 +02:00
commit 299dc239fe
3 changed files with 15 additions and 1 deletions

View file

@ -1627,6 +1627,16 @@ class TestSorted(unittest.TestCase):
self.assertEqual(data, sorted(copy, reverse=1))
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):
s = 'abracadabra'
types = [list, tuple, str]