13 Dec
2011
13 Dec
'11
7:13 a.m.
Hi,
On Tue, Dec 13, 2011 at 11:37, Amaury Forgeot d'Arc
"When sorting a list using the sort() method, attempting to inspect or mutate the content of the list will result in undefined behaviour."
(...) So behaviour is not undefined at all...
No, the behavior _is_ undefined. The comment you cited says that it cannot crash the Python interpreter; additionally, it makes a best-effort attempt at catching such accesses and raising ValueError. But I think I can build a strange-looking example where you mutate a list during sorting and don't get a ValueError (although admittedly it needs a lot of hacking to do that nowadays, e.g. multiple threads). A bientôt, Armin.