[New-bugs-announce] [issue45179] List.sort ERROR
meng_xiaohui
report at bugs.python.org
Sun Sep 12 22:02:42 EDT 2021
New submission from meng_xiaohui <1294886278 at qq.com>:
There is a bug in this method:
L.sort(key=None, reverse=False) -> None
L is an instance of list.
Argument key is a function. If L is in the body of argument key, L is always an empty list in test case, which is wrong
=================
Run this:
F = ['2', '3', '1']
G = ['7', '9', '8']
def key(i):
print(F)
print(G)
res = int(i) + len(F) + len(G)
return res
G.sort(key=key)
F.sort(key=key)
=================
Actual output:
['2', '3', '1']
[]
['2', '3', '1']
[]
['2', '3', '1']
[]
[]
['7', '8', '9']
[]
['7', '8', '9']
[]
['7', '8', '9']
----------
components: Interpreter Core
messages: 401679
nosy: meng_xiaohui
priority: normal
severity: normal
status: open
title: List.sort ERROR
type: behavior
versions: Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45179>
_______________________________________
More information about the New-bugs-announce
mailing list