[ python-Bugs-1695272 ] generator expression produces incomplete list

SourceForge.net noreply at sourceforge.net
Thu Apr 5 22:59:26 CEST 2007


Bugs item #1695272, was opened at 2007-04-05 20:59
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1695272&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: wplapper (wplapper)
Assigned to: Nobody/Anonymous (nobody)
Summary: generator expression produces incomplete list

Initial Comment:
(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

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1695272&group_id=5470


More information about the Python-bugs-list mailing list