Commit 5a318f7c authored by Vitja Makarov's avatar Vitja Makarov

Better fix for cdef generators error

parent 0ea50f34
...@@ -1866,26 +1866,24 @@ class MarkClosureVisitor(CythonTransform): ...@@ -1866,26 +1866,24 @@ class MarkClosureVisitor(CythonTransform):
collector.visitchildren(node) collector.visitchildren(node)
if collector.yields: if collector.yields:
if isinstance(node, Nodes.CFuncDefNode):
# Will report error later
return node
for i, yield_expr in enumerate(collector.yields): for i, yield_expr in enumerate(collector.yields):
yield_expr.label_num = i + 1 yield_expr.label_num = i + 1
gbody = Nodes.GeneratorBodyDefNode(pos=node.pos, gbody = Nodes.GeneratorBodyDefNode(
name=node.name, pos=node.pos, name=node.name, body=node.body)
body=node.body) generator = Nodes.GeneratorDefNode(
generator = Nodes.GeneratorDefNode(pos=node.pos, pos=node.pos, name=node.name, args=node.args,
name=node.name, star_arg=node.star_arg, starstar_arg=node.starstar_arg,
args=node.args, doc=node.doc, decorators=node.decorators,
star_arg=node.star_arg, gbody=gbody, lambda_name=node.lambda_name)
starstar_arg=node.starstar_arg,
doc=node.doc,
decorators=node.decorators,
gbody=gbody,
lambda_name=node.lambda_name)
return generator return generator
return node return node
def visit_CFuncDefNode(self, node): def visit_CFuncDefNode(self, node):
self.visitchildren(node) self.visit_FuncDefNode(node)
if node.needs_closure: if node.needs_closure:
error(node.pos, "closures inside cdef functions not yet supported") error(node.pos, "closures inside cdef functions not yet supported")
return node return node
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment