1 parent 2b34290 commit 6fc36c5Copy full SHA for 6fc36c5
1 file changed
Lib/test/test_types.py
@@ -353,6 +353,21 @@ def myComparison(x,y):
353
z = range(12)
354
z.sort(myComparison)
355
356
+try: z.sort(2)
357
+except TypeError: pass
358
+else: raise TestFailed, 'list sort compare function is not callable'
359
+
360
+def selfmodifyingComparison(x,y):
361
+ z[0] = 1
362
+ return cmp(x, y)
363
+try: z.sort(selfmodifyingComparison)
364
365
+else: raise TestFailed, 'modifying list during sort'
366
367
+try: z.sort(lambda x, y: 's')
368
369
+else: raise TestFailed, 'list sort compare function does not return int'
370
371
# Test extreme cases with long ints
372
a = [0,1,2,3,4]
373
if a[ -pow(2,128L): 3 ] != [0,1,2]:
0 commit comments