Commit 387799ab authored by Xavier Thompson's avatar Xavier Thompson

Sanitize exception checking cpp subscript operations

parent 9c739285
...@@ -3905,7 +3905,7 @@ class IndexNode(_IndexingBaseNode): ...@@ -3905,7 +3905,7 @@ class IndexNode(_IndexingBaseNode):
func_type = func_type.base_type func_type = func_type.base_type
self.exception_check = func_type.exception_check self.exception_check = func_type.exception_check
self.exception_value = func_type.exception_value self.exception_value = func_type.exception_value
if self.exception_check: if self.exception_check == '+':
if not setting: if not setting:
self.is_temp = True self.is_temp = True
if self.exception_value is None: if self.exception_value is None:
...@@ -3949,9 +3949,8 @@ class IndexNode(_IndexingBaseNode): ...@@ -3949,9 +3949,8 @@ class IndexNode(_IndexingBaseNode):
return self return self
self.exception_check = func_type.exception_check self.exception_check = func_type.exception_check
self.exception_value = func_type.exception_value self.exception_value = func_type.exception_value
if self.exception_check: if self.exception_check == '+' and self.exception_value is None:
if self.exception_value is None: env.use_utility_code(UtilityCode.load_cached("CppExceptionConversion", "CppSupport.cpp"))
env.use_utility_code(UtilityCode.load_cached("CppExceptionConversion", "CppSupport.cpp"))
self.index = self.index.coerce_to(func_type.args[0].type, env) self.index = self.index.coerce_to(func_type.args[0].type, env)
if not deleting: if not deleting:
self.type = func_type.args[1].type self.type = func_type.args[1].type
...@@ -4265,7 +4264,7 @@ class IndexNode(_IndexingBaseNode): ...@@ -4265,7 +4264,7 @@ class IndexNode(_IndexingBaseNode):
function = "__Pyx_GetItemInt_ByteArray" function = "__Pyx_GetItemInt_ByteArray"
error_value = '-1' error_value = '-1'
utility_code = UtilityCode.load_cached("GetItemIntByteArray", "StringTools.c") utility_code = UtilityCode.load_cached("GetItemIntByteArray", "StringTools.c")
elif not (self.base.type.is_cpp_class and self.exception_check): elif not (self.base.type.is_cpp_class and self.exception_check == '+'):
assert False, "unexpected type %s and base type %s for indexing" % ( assert False, "unexpected type %s and base type %s for indexing" % (
self.type, self.base.type) self.type, self.base.type)
...@@ -4277,7 +4276,7 @@ class IndexNode(_IndexingBaseNode): ...@@ -4277,7 +4276,7 @@ class IndexNode(_IndexingBaseNode):
else: else:
index_code = self.index.py_result() index_code = self.index.py_result()
if self.base.type.is_cpp_class and self.exception_check: if self.base.type.is_cpp_class and self.exception_check == '+':
base_result = self.base.result() base_result = self.base.result()
if self.base.type.is_cyp_class: if self.base.type.is_cyp_class:
base_result = "(*%s)" % base_result base_result = "(*%s)" % base_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