@@ -5490,31 +5490,29 @@ push_inlined_comprehension_state(struct compiler *c, location loc,
5490
5490
}
5491
5491
Py_DECREF (outv );
5492
5492
}
5493
- if (outsc == LOCAL || outsc == CELL || outsc == FREE ) {
5494
- // local names bound in comprehension must be isolated from
5495
- // outer scope; push existing value (which may be NULL if
5496
- // not defined) on stack
5493
+ // local names bound in comprehension must be isolated from
5494
+ // outer scope; push existing value (which may be NULL if
5495
+ // not defined) on stack
5496
+ if (state -> pushed_locals == NULL ) {
5497
+ state -> pushed_locals = PyList_New (0 );
5497
5498
if (state -> pushed_locals == NULL ) {
5498
- state -> pushed_locals = PyList_New (0 );
5499
- if (state -> pushed_locals == NULL ) {
5500
- return ERROR ;
5501
- }
5502
- }
5503
- // in the case of a cell, this will actually push the cell
5504
- // itself to the stack, then we'll create a new one for the
5505
- // comprehension and restore the original one after
5506
- ADDOP_NAME (c , loc , LOAD_FAST_AND_CLEAR , k , varnames );
5507
- if (scope == CELL ) {
5508
- if (outsc == FREE ) {
5509
- ADDOP_NAME (c , loc , MAKE_CELL , k , freevars );
5510
- } else {
5511
- ADDOP_NAME (c , loc , MAKE_CELL , k , cellvars );
5512
- }
5513
- }
5514
- if (PyList_Append (state -> pushed_locals , k ) < 0 ) {
5515
5499
return ERROR ;
5516
5500
}
5517
5501
}
5502
+ // in the case of a cell, this will actually push the cell
5503
+ // itself to the stack, then we'll create a new one for the
5504
+ // comprehension and restore the original one after
5505
+ ADDOP_NAME (c , loc , LOAD_FAST_AND_CLEAR , k , varnames );
5506
+ if (scope == CELL ) {
5507
+ if (outsc == FREE ) {
5508
+ ADDOP_NAME (c , loc , MAKE_CELL , k , freevars );
5509
+ } else {
5510
+ ADDOP_NAME (c , loc , MAKE_CELL , k , cellvars );
5511
+ }
5512
+ }
5513
+ if (PyList_Append (state -> pushed_locals , k ) < 0 ) {
5514
+ return ERROR ;
5515
+ }
5518
5516
}
5519
5517
}
5520
5518
if (state -> pushed_locals ) {
0 commit comments