diff --git a/Lib/test/test_listcomps.py b/Lib/test/test_listcomps.py index 1a88e8cc1a5cc9..1e1e9e32dc2f76 100644 --- a/Lib/test/test_listcomps.py +++ b/Lib/test/test_listcomps.py @@ -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} diff --git a/Python/flowgraph.c b/Python/flowgraph.c index 69d7e0a872aa48..eb037b54aacc0d 100644 --- a/Python/flowgraph.c +++ b/Python/flowgraph.c @@ -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,