Commit 81cd759d authored by Stefan Behnel's avatar Stefan Behnel

clean up and simplify error handling code generation in IndexNode

parent 346363f6
...@@ -3631,16 +3631,15 @@ class IndexNode(_IndexingBaseNode): ...@@ -3631,16 +3631,15 @@ class IndexNode(_IndexingBaseNode):
self.index.result()), self.index.result()),
self.exception_value, self.in_nogil_context) self.exception_value, self.in_nogil_context)
else: else:
error_check = '!%s' if error_value == 'NULL' else '%%s == %s' % error_value
code.putln( code.putln(
"%s = %s(%s, %s%s); if (unlikely(%s == %s)) %s;" % ( "%s = %s(%s, %s%s); %s" % (
self.result(), self.result(),
function, function,
self.base.py_result(), self.base.py_result(),
index_code, index_code,
self.extra_index_params(code), self.extra_index_params(code),
self.result(), code.error_goto_if(error_check % self.result(), self.pos)))
error_value,
code.error_goto(self.pos)))
if self.type.is_pyobject: if self.type.is_pyobject:
code.put_gotref(self.py_result()) code.put_gotref(self.py_result())
...@@ -3668,14 +3667,14 @@ class IndexNode(_IndexingBaseNode): ...@@ -3668,14 +3667,14 @@ class IndexNode(_IndexingBaseNode):
# (PyTuple_SetItem() is for creating new tuples from scratch). # (PyTuple_SetItem() is for creating new tuples from scratch).
else: else:
function = "PyObject_SetItem" function = "PyObject_SetItem"
code.putln( code.putln(code.error_goto_if_neg(
"if (unlikely(%s(%s, %s, %s%s) < 0)) %s" % ( "%s(%s, %s, %s%s)" % (
function, function,
self.base.py_result(), self.base.py_result(),
index_code, index_code,
value_code, value_code,
self.extra_index_params(code), self.extra_index_params(code)),
code.error_goto(self.pos))) self.pos))
def generate_assignment_code(self, rhs, code, overloaded_assignment=False, def generate_assignment_code(self, rhs, code, overloaded_assignment=False,
exception_check=None, exception_value=None): exception_check=None, exception_value=None):
...@@ -3760,13 +3759,13 @@ class IndexNode(_IndexingBaseNode): ...@@ -3760,13 +3759,13 @@ class IndexNode(_IndexingBaseNode):
function = "PyDict_DelItem" function = "PyDict_DelItem"
else: else:
function = "PyObject_DelItem" function = "PyObject_DelItem"
code.putln( code.putln(code.error_goto_if_neg(
"if (%s(%s, %s%s) < 0) %s" % ( "%s(%s, %s%s)" % (
function, function,
self.base.py_result(), self.base.py_result(),
index_code, index_code,
self.extra_index_params(code), self.extra_index_params(code)),
code.error_goto(self.pos))) self.pos))
self.generate_subexpr_disposal_code(code) self.generate_subexpr_disposal_code(code)
self.free_subexpr_temps(code) self.free_subexpr_temps(code)
......
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