Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e241e29

Browse files
committed
Add test for a list comprehension that is nested in the left-hand part
of another list comp. This caused crashes reported as SF bugs 409230 and 407800. Note that the new tests are in a function so that the name lookup code isn't affected by how many *other* list comprehensions are in the same scope.
1 parent 23b4227 commit e241e29

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

Lib/test/output/test_grammar

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ classdef
6060
[(1, 'Apple'), (1, 'Banana'), (1, 'Coconut'), (2, 'Apple'), (2, 'Banana'), (2, 'Coconut'), (3, 'Apple'), (3, 'Banana'), (3, 'Coconut'), (4, 'Apple'), (4, 'Banana'), (4, 'Coconut'), (5, 'Apple'), (5, 'Banana'), (5, 'Coconut')]
6161
[(1, 'Banana'), (1, 'Coconut'), (2, 'Banana'), (2, 'Coconut'), (3, 'Banana'), (3, 'Coconut'), (4, 'Banana'), (4, 'Coconut'), (5, 'Banana'), (5, 'Coconut')]
6262
[0, 0, 0]
63+
[[1, 2], [3, 4], [5, 6]]
6364
[('Boeing', 'Airliner'), ('Boeing', 'Engine'), ('Ford', 'Engine'), ('Macdonalds', 'Cheeseburger')]

Lib/test/test_grammar.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,11 @@ def test_in_func(l):
661661

662662
print test_in_func(nums)
663663

664+
def test_nested_front():
665+
print [[y for y in [x, x + 1]] for x in [1,3,5]]
666+
667+
test_nested_front()
668+
664669
check_syntax("[i, s for i in nums for s in strs]")
665670
check_syntax("[x if y]")
666671

0 commit comments

Comments
 (0)