Commit 93677f0
committed
* drop the unreasonable list invariant that ob_item should never come back
to NULL during the lifetime of the object.
* listobject.c nevertheless did not conform to the other invariants,
either; fixed.
* listobject.c now uses list_clear() as the obvious internal way to clear
a list, instead of abusing list_ass_slice() for that. It makes it easier
to enforce the invariant about ob_item == NULL.
* listsort() sets allocated to -1 during sort; any mutation will set it
to a value >= 0, so it is a safe way to detect mutation. A negative
value for allocated does not cause a problem elsewhere currently.
test_sort.py has a new test for this fix.
* listsort() leak: if items were added to the list during the sort, AND if
these items had a __del__ that puts still more stuff into the list,
then this more stuff (and the PyObject** array to hold them) were
overridden at the end of listsort() and never released.1 parent f414fc4 commit 93677f0
3 files changed
Lines changed: 64 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
35 | | - | |
| 33 | + | |
36 | 34 | | |
37 | 35 | | |
38 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
153 | 170 | | |
154 | 171 | | |
155 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
485 | 485 | | |
486 | 486 | | |
487 | 487 | | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
488 | 511 | | |
489 | 512 | | |
490 | 513 | | |
| |||
530 | 553 | | |
531 | 554 | | |
532 | 555 | | |
533 | | - | |
| 556 | + | |
534 | 557 | | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
535 | 563 | | |
536 | 564 | | |
537 | 565 | | |
| |||
576 | 604 | | |
577 | 605 | | |
578 | 606 | | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | 607 | | |
584 | 608 | | |
585 | 609 | | |
| |||
609 | 633 | | |
610 | 634 | | |
611 | 635 | | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
| 636 | + | |
618 | 637 | | |
619 | 638 | | |
620 | 639 | | |
| |||
1908 | 1927 | | |
1909 | 1928 | | |
1910 | 1929 | | |
| 1930 | + | |
1911 | 1931 | | |
1912 | 1932 | | |
1913 | 1933 | | |
| |||
1942 | 1962 | | |
1943 | 1963 | | |
1944 | 1964 | | |
1945 | | - | |
| 1965 | + | |
1946 | 1966 | | |
| 1967 | + | |
1947 | 1968 | | |
1948 | 1969 | | |
1949 | 1970 | | |
| |||
2032 | 2053 | | |
2033 | 2054 | | |
2034 | 2055 | | |
2035 | | - | |
| 2056 | + | |
2036 | 2057 | | |
2037 | 2058 | | |
2038 | 2059 | | |
| |||
2046 | 2067 | | |
2047 | 2068 | | |
2048 | 2069 | | |
2049 | | - | |
2050 | | - | |
2051 | | - | |
2052 | | - | |
| 2070 | + | |
| 2071 | + | |
2053 | 2072 | | |
2054 | 2073 | | |
2055 | 2074 | | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
2056 | 2083 | | |
2057 | 2084 | | |
2058 | 2085 | | |
| |||
2207 | 2234 | | |
2208 | 2235 | | |
2209 | 2236 | | |
2210 | | - | |
2211 | | - | |
2212 | | - | |
2213 | | - | |
2214 | | - | |
2215 | | - | |
2216 | | - | |
2217 | 2237 | | |
2218 | 2238 | | |
2219 | 2239 | | |
| |||
2295 | 2315 | | |
2296 | 2316 | | |
2297 | 2317 | | |
2298 | | - | |
2299 | | - | |
2300 | | - | |
2301 | | - | |
| 2318 | + | |
| 2319 | + | |
2302 | 2320 | | |
2303 | 2321 | | |
2304 | 2322 | | |
| |||
0 commit comments