Commit fb0630cf authored by Xavier Thompson's avatar Xavier Thompson

Raise a proper exception when runtime isolation check fails

parent d9ca179c
...@@ -11357,6 +11357,7 @@ class ConsumeNode(ExprNode): ...@@ -11357,6 +11357,7 @@ class ConsumeNode(ExprNode):
# #
# operand ExprNode # operand ExprNode
# #
# nogil boolean used internally
# generate_runtime_check boolean used internally # generate_runtime_check boolean used internally
# operand_is_named boolean used internally # operand_is_named boolean used internally
...@@ -11370,6 +11371,7 @@ class ConsumeNode(ExprNode): ...@@ -11370,6 +11371,7 @@ class ConsumeNode(ExprNode):
return operand_type return operand_type
def analyse_types(self, env): def analyse_types(self, env):
self.nogil = env.nogil
self.operand = self.operand.analyse_types(env) self.operand = self.operand.analyse_types(env)
operand_type = self.operand.type operand_type = self.operand.type
if not operand_type.is_cyp_class: if not operand_type.is_cyp_class:
...@@ -11415,7 +11417,17 @@ class ConsumeNode(ExprNode): ...@@ -11415,7 +11417,17 @@ class ConsumeNode(ExprNode):
code.putln("%s = %s;" % (self.result(), operand_result)) code.putln("%s = %s;" % (self.result(), operand_result))
if self.generate_runtime_check: if self.generate_runtime_check:
code.putln("if (!%s->CyObject_iso()) {" % self.result()) code.putln("if (!%s->CyObject_iso()) {" % self.result())
code.putln("std::terminate();") if self.nogil:
code.putln("#ifdef WITH_THREAD")
code.putln("PyGILState_STATE _save = PyGILState_Ensure();")
code.putln("#endif")
code.putln("PyErr_SetString(PyExc_TypeError, \"'consume' operand is not isolated\");")
if self.nogil:
code.putln("#ifdef WITH_THREAD")
code.putln("PyGILState_Release(_save);")
code.putln("#endif")
code.putln(
code.error_goto(self.pos))
code.putln("}") code.putln("}")
# We steal the reference of the operand. # We steal the reference of the operand.
code.putln("%s = NULL;" % operand_result) code.putln("%s = NULL;" % operand_result)
......
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