Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carljm committed Sep 27, 2024
1 parent 34b8532 commit cbad048
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions Lib/test/test_listcomps.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,25 +754,27 @@ def test_freevar_through_scope_containing_comprehension(self):
code = """
x = 1
def f():
[x for x in [1]]
for z in [x for x in [2]]:
pass
def g():
return x
return g()
y = f()
return g(), z
y, z = f()
"""
self._check_in_scopes(code, {"x": 1, "y": 1}, scopes=["module", "function"])
self._check_in_scopes(code, {"x": 1, "y": 1, "z": 2}, scopes=["module", "function"])

def test_freevar_through_scope_containing_comprehension_with_cell(self):
code = """
x = 1
def f():
[lambda: x for x in [1]]
for l in [lambda: x for x in [2]]:
z = l()
def g():
return x
return g()
y = f()
return g(), z
y, z = f()
"""
self._check_in_scopes(code, {"x": 1, "y": 1}, scopes=["function"])
self._check_in_scopes(code, {"x": 1, "y": 1, "z": 2}, scopes=["function"])

__test__ = {'doctests' : doctests}

Expand Down
2 changes: 1 addition & 1 deletion Python/flowgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -2700,7 +2700,7 @@ insert_prefix_instructions(_PyCompile_CodeUnitMetadata *umd, basicblock *entrybl
}
cfg_instr make_cell = {
.i_opcode = MAKE_CELL,
// This will get fixed in offset_derefs().
// This will get fixed in fix_cell_offsets().
.i_oparg = oldindex,
.i_loc = NO_LOCATION,
.i_target = NULL,
Expand Down

0 comments on commit cbad048

Please sign in to comment.