bpo-36218: Fix handling of heterogeneous values in list.sort (GH-12209)

This commit is contained in:
Rémi Lapeyre 2019-03-25 08:25:37 +01:00 committed by Raymond Hettinger
parent 9dcc095f45
commit dd5417afcf
3 changed files with 29 additions and 11 deletions

View file

@ -373,6 +373,11 @@ class TestOptimizedCompares(unittest.TestCase):
check_against_PyObject_RichCompareBool(self, [float('nan')]*100)
check_against_PyObject_RichCompareBool(self, [float('nan') for
_ in range(100)])
def test_not_all_tuples(self):
self.assertRaises(TypeError, [(1.0, 1.0), (False, "A"), 6].sort)
self.assertRaises(TypeError, [('a', 1), (1, 'a')].sort)
self.assertRaises(TypeError, [(1, 'a'), ('a', 1)].sort)
#==============================================================================
if __name__ == "__main__":