(original) (raw)

2011/12/13 Armin Rigo <arigo@tunes.org>
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).

I'm interested to see how!
The current implementation installs an empty array in the list,
and the initial array is only held by a local variable in listsort().
even�gc.get\_referrers() can return the empty list...

--
Amaury Forgeot d'Arc