summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-07-29 04:07:15 (GMT)
committerTim Peters <tim.peters@gmail.com>2004-07-29 04:07:15 (GMT)
commit51b4ade30615dccaa7f591456528821f4320d5ff (patch)
tree523a2ab5f3c3154c3e175b6adec26eefdf23cfae /Include
parent014f103705afef0c1c6d7dc740e6a4f21b2da794 (diff)
downloadcpython-51b4ade30615dccaa7f591456528821f4320d5ff.zip
cpython-51b4ade30615dccaa7f591456528821f4320d5ff.tar.gz
cpython-51b4ade30615dccaa7f591456528821f4320d5ff.tar.bz2
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.
Diffstat (limited to 'Include')
-rw-r--r--Include/listobject.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/Include/listobject.h b/Include/listobject.h
index 62a8518..ffce029 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;