Commit 19c72a93 authored by Marius Wachtler's avatar Marius Wachtler

Don't abort when generating code for a __getitem__ on a known type which has no __getitem__

parent a3d1cbb3
......@@ -352,6 +352,7 @@ public:
= var->getType()->getattrType(attr, true)->callType(ArgPassSpec(1), { SLICE }, NULL);
assert(return_type->getConcreteType() == return_type);
if (return_type != UNDEF) {
llvm::Value* cstart, *cstop;
cstart = slice_val.start ? slice_val.start->makeConverted(emitter, UNKNOWN)->getValue()
: getNullPtr(g.llvm_value_type_ptr);
......@@ -362,8 +363,11 @@ public:
= emitter.createCall3(info.unw_info, g.funcs.apply_slice, var->getValue(), cstart, cstop);
emitter.checkAndPropagateCapiException(info.unw_info, r, getNullPtr(g.llvm_value_type_ptr));
return new ConcreteCompilerVariable(static_cast<ConcreteCompilerType*>(return_type), r, true);
} else {
// TODO: we could directly emit an exception if we know getitem is undefined but for now let it just
// call the normal getitem which will raise the exception
}
}
}
......
......@@ -63,3 +63,27 @@ try:
f(i == 9999)
except TypeError, e:
print e
# make sure we don't abort when calling getitem
def f(error):
i = 1
f = 1.0
l = 1l
if error:
i[:]
f[:]
l[:]
i[1]
f[1]
l[1]
i[1:2]
f[1:2]
l[1:2]
try:
for i in range(10000):
f(i == 9999)
except TypeError as e:
print e
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