mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Allow list sort's comparison function to explicitly be None. See SF patch
661092.
This commit is contained in:
parent
fe8496ca03
commit
4abd5f0fce
4 changed files with 34 additions and 6 deletions
|
|
@ -145,6 +145,26 @@ def bug453523():
|
|||
|
||||
bug453523()
|
||||
|
||||
def cmpNone():
|
||||
global nerrors
|
||||
|
||||
if verbose:
|
||||
print "Testing None as a comparison function."
|
||||
|
||||
L = range(50)
|
||||
random.shuffle(L)
|
||||
try:
|
||||
L.sort(None)
|
||||
except TypeError:
|
||||
print " Passing None as cmpfunc failed."
|
||||
nerrors += 1
|
||||
else:
|
||||
if L != range(50):
|
||||
print " Passing None as cmpfunc failed."
|
||||
nerrors += 1
|
||||
|
||||
cmpNone()
|
||||
|
||||
if nerrors:
|
||||
print "Test failed", nerrors
|
||||
elif verbose:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue