SF patch 637176: list.sort crasher

Armin Rigo's Draconian but effective fix for

SF bug 453523: list.sort crasher

slightly fiddled to catch more cases of list mutation.  The dreaded
internal "immutable list type" is gone!  OTOH, if you look at a list
*while* it's being sorted now, it will appear to be empty.  Better
than a core dump.
This commit is contained in:
Tim Peters 2002-11-12 22:08:10 +00:00
parent 4b9ed2f346
commit b9099c3df4
5 changed files with 78 additions and 100 deletions

View file

@ -922,7 +922,7 @@ The following operations are defined on mutable sequence types (where
\lineiii{\var{s}.reverse()}
{reverses the items of \var{s} in place}{(6)}
\lineiii{\var{s}.sort(\optional{\var{cmpfunc}})}
{sort the items of \var{s} in place}{(6), (7), (8)}
{sort the items of \var{s} in place}{(6), (7), (8), (9)}
\end{tableiii}
\indexiv{operations on}{mutable}{sequence}{types}
\indexiii{operations on}{sequence}{types}
@ -980,6 +980,12 @@ Notes:
Python 2.2. The C implementation of Python 2.3 introduced a stable
\method{sort()} method, but code that intends to be portable across
implementations and versions must not rely on stability.
\item[(9)] While a list is being sorted, the effect of attempting to
mutate, or even inspect, the list is undefined. The C implementation
of Python 2.3 makes the list appear empty for the duration, and raises
\exception{ValueError} if it can detect that the list has been
mutated during a sort.
\end{description}