Mercurial > cpython-lru_cache-weakref
diff Doc/lib/libstdtypes.tex @ 26161:dd10d97d329a legacy-trunk
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.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Tue, 12 Nov 2002 22:08:10 +0000 |
| parents | 50905db35da5 |
| children | 60d809a25bae |
line wrap: on
line diff
--- a/Doc/lib/libstdtypes.tex Tue Nov 12 22:07:11 2002 +0000 +++ b/Doc/lib/libstdtypes.tex Tue Nov 12 22:08:10 2002 +0000 @@ -922,7 +922,7 @@ \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 @@ 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}
