Commit 613c070f authored by Ian Henriksen's avatar Ian Henriksen

Fixed C++ exception handling for indexing when it is not used for

assignment.
parent 57a5ef18
......@@ -3263,6 +3263,10 @@ class IndexNode(_IndexingBaseNode):
func_type = function.type
if func_type.is_ptr:
func_type = func_type.base_type
self.exception_check = func_type.exception_check
self.exception_value = func_type.exception_value
if func_type.exception_check and not setting:
self.is_temp = True
self.index = self.index.coerce_to(func_type.args[0].type, env)
self.type = func_type.return_type
if setting and not func_type.return_type.is_reference:
......@@ -3532,7 +3536,7 @@ class IndexNode(_IndexingBaseNode):
error_value = '-1'
code.globalstate.use_utility_code(
UtilityCode.load_cached("GetItemIntByteArray", "StringTools.c"))
else:
elif not (self.base.type.is_cpp_class and self.exception_check):
assert False, "unexpected type %s and base type %s for indexing" % (
self.type, self.base.type)
......@@ -3541,6 +3545,12 @@ class IndexNode(_IndexingBaseNode):
else:
index_code = self.index.py_result()
if self.base.type.is_cpp_class and self.exception_check:
translate_cpp_exception(code, self.pos,
"%s = %s[%s];" % (self.result(), self.base.result(),
self.index.result()),
self.exception_value, self.in_nogil_context)
else:
code.putln(
"%s = %s(%s, %s%s); if (unlikely(%s == %s)) %s;" % (
self.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