Commit ac1d79a6 authored by Stefan Behnel's avatar Stefan Behnel

Improve error handling in "cython.array" creation code to avoid calling...

Improve error handling in "cython.array" creation code to avoid calling Py_BuildValue() with an exception set if "__pyx_format_from_typeinfo()" failed.
parent 8cf3192d
...@@ -10729,17 +10729,20 @@ class CythonArrayNode(ExprNode): ...@@ -10729,17 +10729,20 @@ class CythonArrayNode(ExprNode):
code.putln(code.error_goto(self.operand.pos)) code.putln(code.error_goto(self.operand.pos))
code.putln("}") code.putln("}")
code.putln("%s = __pyx_format_from_typeinfo(&%s);" % code.putln("%s = __pyx_format_from_typeinfo(&%s); %s" % (
(format_temp, type_info)) format_temp,
buildvalue_fmt = " __PYX_BUILD_PY_SSIZE_T " * len(shapes) type_info,
code.putln('%s = Py_BuildValue((char*) "(" %s ")", %s);' % ( code.error_goto_if_null(format_temp, self.pos),
shapes_temp, buildvalue_fmt, ", ".join(shapes))) ))
code.put_gotref(format_temp, py_object_type)
err = "!%s || !%s || !PyBytes_AsString(%s)" % (format_temp, buildvalue_fmt = " __PYX_BUILD_PY_SSIZE_T " * len(shapes)
code.putln('%s = Py_BuildValue((char*) "(" %s ")", %s); %s' % (
shapes_temp, shapes_temp,
format_temp) buildvalue_fmt,
code.putln(code.error_goto_if(err, self.pos)) ", ".join(shapes),
code.put_gotref(format_temp, py_object_type) code.error_goto_if_null(shapes_temp, self.pos),
))
code.put_gotref(shapes_temp, py_object_type) code.put_gotref(shapes_temp, py_object_type)
tup = (self.result(), shapes_temp, itemsize, format_temp, tup = (self.result(), shapes_temp, itemsize, format_temp,
......
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