[Python-Dev] IEEE/ISO draft on Python vulnerabilities

Armin Rigo arigo at tunes.org
Tue Dec 13 14:13:55 CET 2011


Hi,

On Tue, Dec 13, 2011 at 11:37, Amaury Forgeot d'Arc <amauryfa at gmail.com> wrote:
>> "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.


More information about the Python-Dev mailing list