Fix obscure breakage (relative to 2.3) in listsort: the test for list

mutation during list.sort() used to rely on that listobject.c always
NULL'ed ob_item when ob_size fell to 0.  That's no longer true, so the
test for list mutation during a sort is no longer reliable.  Changed the
test to rely instead on that listobject.c now never NULLs-out ob_item
after (if ever) ob_item gets a non-NULL value.  This new assumption is
also documented now, as a required invariant in listobject.h.

The new assumption allowed some real simplification to some of the
hairier code in listsort(), so is a Good Thing on that count.
This commit is contained in:
Tim Peters 2004-07-29 04:07:15 +00:00
parent 014f103705
commit 51b4ade306
2 changed files with 15 additions and 26 deletions

View file

@ -30,6 +30,9 @@ typedef struct {
* 0 <= ob_size <= allocated
* len(list) == ob_size
* ob_item == NULL implies ob_size == allocated == 0
* If ob_item ever becomes non-NULL, it remains non-NULL for the
* life of the list object. The check for mutation in list.sort()
* relies on this odd detail.
*/
int allocated;
} PyListObject;