Commit cc1c499b authored by Robert Bradshaw's avatar Robert Bradshaw

Fix bare return for closure creation failure.

Re-use, rather than duplicate, error exit code.
parent 09f6874a
...@@ -1848,28 +1848,15 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -1848,28 +1848,15 @@ class FuncDefNode(StatNode, BlockNode):
lenv.scope_class.type.typeptr_cname, lenv.scope_class.type.typeptr_cname,
Naming.empty_tuple)) Naming.empty_tuple))
code.putln("if (unlikely(!%s)) {" % Naming.cur_scope_cname) code.putln("if (unlikely(!%s)) {" % Naming.cur_scope_cname)
if is_getbuffer_slot: # Scope unconditionally DECREFed on return.
self.getbuffer_error_cleanup(code) code.putln("%s = %s;" % (
Naming.cur_scope_cname,
if use_refnanny: lenv.scope_class.type.cast_code("Py_None")));
code.put_finish_refcount_context() code.put_incref("Py_None", py_object_type);
if acquire_gil or acquire_gil_for_var_decls_only: code.putln(code.error_goto(self.pos))
code.put_release_ensured_gil() code.putln("} else {")
# FIXME: what if the error return value is a Python 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) code.put_gotref(Naming.cur_scope_cname)
code.putln("}")
# Note that it is unsafe to decref the scope at this point. # Note that it is unsafe to decref the scope at this point.
if self.needs_outer_scope: if self.needs_outer_scope:
if self.is_cyfunction: if self.is_cyfunction:
......
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