|
11 | 11 | from compiler import ast, parse, walk |
12 | 12 | from compiler import pyassem, misc, future, symbols |
13 | 13 | from compiler.consts import SC_LOCAL, SC_GLOBAL, SC_FREE, SC_CELL |
14 | | -from compiler.pyassem import CO_VARARGS, CO_VARKEYWORDS, CO_NEWLOCALS,\ |
15 | | - CO_NESTED, TupleArg |
| 14 | +from compiler.consts import CO_VARARGS, CO_VARKEYWORDS, CO_NEWLOCALS,\ |
| 15 | + CO_NESTED, CO_GENERATOR |
| 16 | +from compiler.pyassem import TupleArg |
16 | 17 |
|
17 | 18 | # Do we have Python 1.x or Python 2.x? |
18 | 19 | try: |
@@ -495,10 +496,10 @@ def visitListCompFor(self, node): |
495 | 496 | anchor = self.newBlock() |
496 | 497 |
|
497 | 498 | self.visit(node.list) |
498 | | - self.visit(ast.Const(0)) |
| 499 | + self.emit('GET_ITER') |
499 | 500 | self.nextBlock(start) |
500 | 501 | self.emit('SET_LINENO', node.lineno) |
501 | | - self.emit('FOR_LOOP', anchor) |
| 502 | + self.emit('FOR_ITER', anchor) |
502 | 503 | self.nextBlock() |
503 | 504 | self.visit(node.assign) |
504 | 505 | return start, anchor |
@@ -1199,6 +1200,8 @@ def __init__(self, func, filename, scopes, isLambda, class_name): |
1199 | 1200 | self.__super_init(func, filename, scopes, isLambda, class_name) |
1200 | 1201 | self.graph.setFreeVars(self.scope.get_free_vars()) |
1201 | 1202 | self.graph.setCellVars(self.scope.get_cell_vars()) |
| 1203 | + if self.scope.generator is not None: |
| 1204 | + self.graph.setFlag(CO_GENERATOR) |
1202 | 1205 | ## self.graph.setFlag(CO_NESTED) |
1203 | 1206 |
|
1204 | 1207 | class AbstractClassCode: |
|
0 commit comments