Issue 1695272: generator expression produces incomplete list (original) (raw)

(eliminate(values, s, d2) for d2 in values[s] if d2 != d)
is producing incomplete results for the above statement.

If the statement split into two parts, the results are correct. xxx = [d2 for d2 in values[s] if d2 != d] zzz = (eliminate(values, s, d2) for d2 in xxx) return all(zzz)

First create temporary list xxx and then apply generator expression zzz.

The problem has been observed for python 2.4.3 and 2.5.0.0, on Windows, Solaris (x86) and on Linux. For me, the error pattern is consistent for all test cases I ran.

This is the output of the attach script: wrong assign.s 0 d 2 val [1, 2, 3, 4, 5, 6, 7, 8, 9] eliminate.s 0 d 1 val [1, 2, 3, 4, 5, 6, 7, 8, 9] eliminate.s 0 d 3 val [2, 3, 4, 5, 6, 7, 8, 9] eliminate.s 0 d 5 val [2, 4, 5, 6, 7, 8, 9] eliminate.s 0 d 7 val [2, 4, 6, 7, 8, 9] eliminate.s 0 d 9 val [2, 4, 6, 8, 9]

right assign.s 0 d 2 val [1, 2, 3, 4, 5, 6, 7, 8, 9] eliminate.s 0 d 1 val [1, 2, 3, 4, 5, 6, 7, 8, 9] eliminate.s 0 d 3 val [2, 3, 4, 5, 6, 7, 8, 9] eliminate.s 0 d 4 val [2, 4, 5, 6, 7, 8, 9] eliminate.s 0 d 5 val [2, 5, 6, 7, 8, 9] eliminate.s 0 d 6 val [2, 6, 7, 8, 9] eliminate.s 0 d 7 val [2, 7, 8, 9] eliminate.s 0 d 8 val [2, 8, 9] eliminate.s 0 d 9 val [2, 9]

The test program is supposed to remove ALL numbers from the list, apart from "2". In the wrong case, only odd numbers are removed.

Best regards, Winfried