Commit f8b952c1 authored by Stefan Behnel's avatar Stefan Behnel

fix error handling for closure creation in cdef void functions

parent 937f8314
......@@ -1828,7 +1828,17 @@ class FuncDefNode(StatNode, BlockNode):
code.put_release_ensured_gil()
# FIXME: what if the error return value is a Python value?
code.putln("return %s;" % self.error_value())
err_val = self.error_value()
if err_val is None:
if not self.caller_will_check_exceptions():
warning(self.entry.pos,
"Unraisable exception in function '%s'." %
self.entry.qualified_name, 0)
code.put_unraisable(self.entry.qualified_name, lenv.nogil)
#if self.return_type.is_void:
code.putln("return;")
else:
code.putln("return %s;" % err_val)
code.putln("}")
code.put_gotref(Naming.cur_scope_cname)
# Note that it is unsafe to decref the scope at this point.
......
......@@ -9,6 +9,23 @@ def call_f(x):
"""
return f(x)
cdef f(x): # def here => works fine
def g(y): return y*x # cdef here => compile error
return g(x) # faults@ INCREF(.*cur_scope->.*v_x
def g(y): return y*x # cdef here => compile error
return g(x) # faults@ INCREF(.*cur_scope->.*v_x
def closure_in_void():
"""
>>> genex = closure_in_void()
>>> list(genex)
['a', 'b', 'c']
"""
l = []
add_gen(l)
return l[0]
cdef void add_gen(l):
x = "abc"
l.append((c for c in x))
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