Commit a5b3d89b authored by scoder's avatar scoder

Merge pull request #32 from vitek/unreachable_fix

fix for unreachable yield in generators
parents 109185f0 019551db
...@@ -5253,7 +5253,6 @@ class YieldExprNode(ExprNode): ...@@ -5253,7 +5253,6 @@ class YieldExprNode(ExprNode):
self.arg.analyse_types(env) self.arg.analyse_types(env)
if not self.arg.type.is_pyobject: if not self.arg.type.is_pyobject:
self.arg = self.arg.coerce_to_pyobject(env) self.arg = self.arg.coerce_to_pyobject(env)
env.use_utility_code(generator_utility_code)
def generate_evaluation_code(self, code): def generate_evaluation_code(self, code):
self.label_name = code.new_label('resume_from_yield') self.label_name = code.new_label('resume_from_yield')
......
...@@ -2989,6 +2989,9 @@ class GeneratorDefNode(DefNode): ...@@ -2989,6 +2989,9 @@ class GeneratorDefNode(DefNode):
code.putln("return (PyObject *) %s;" % Naming.cur_scope_cname); code.putln("return (PyObject *) %s;" % Naming.cur_scope_cname);
def generate_function_definitions(self, env, code): def generate_function_definitions(self, env, code):
from ExprNodes import generator_utility_code
env.use_utility_code(generator_utility_code)
self.gbody.generate_function_header(code, proto=True) self.gbody.generate_function_header(code, proto=True)
super(GeneratorDefNode, self).generate_function_definitions(env, code) super(GeneratorDefNode, self).generate_function_definitions(env, code)
self.gbody.generate_function_definitions(env, code) self.gbody.generate_function_definitions(env, code)
......
# mode: run
# tag: generators unreachable
def with_yield_removed():
"""
>>> o = with_yield_removed()
>>> list(o)
[]
"""
return
yield
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