From 51b4ade30615dccaa7f591456528821f4320d5ff Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Thu, 29 Jul 2004 04:07:15 +0000 Subject: 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. --- Include/listobject.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Include/listobject.h') diff --git a/Include/listobject.h b/Include/listobject.h index 62a8518080..ffce029fac 100644 --- a/Include/listobject.h +++ b/Include/listobject.h @@ -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; -- cgit v1.2.1