Commit 38f2aef8 authored by Joris Vankerschaver's avatar Joris Vankerschaver

Raise TypeError when slice type is not understood.

parent 8046d0e6
...@@ -92,13 +92,13 @@ Box* tupleGetitemSlice(BoxedTuple* self, BoxedSlice* slice) { ...@@ -92,13 +92,13 @@ Box* tupleGetitemSlice(BoxedTuple* self, BoxedSlice* slice) {
Box* tupleGetitem(BoxedTuple* self, Box* slice) { Box* tupleGetitem(BoxedTuple* self, Box* slice) {
assert(self->cls == tuple_cls); assert(self->cls == tuple_cls);
if (slice->cls == int_cls) { if (slice->cls == int_cls)
return tupleGetitemInt(self, static_cast<BoxedInt*>(slice)); return tupleGetitemInt(self, static_cast<BoxedInt*>(slice));
} else if (slice->cls == slice_cls) { else if (slice->cls == slice_cls)
return tupleGetitemSlice(self, static_cast<BoxedSlice*>(slice)); return tupleGetitemSlice(self, static_cast<BoxedSlice*>(slice));
} else { else
RELEASE_ASSERT(0, ""); // Fix this. raiseExcHelper(TypeError,
} "tuple indices must be integers, not %s", getTypeName(slice)->c_str());
} }
Box* tupleAdd(BoxedTuple* self, Box* rhs) { Box* tupleAdd(BoxedTuple* self, Box* rhs) {
......
...@@ -101,3 +101,13 @@ print t[5:1:-1] ...@@ -101,3 +101,13 @@ print t[5:1:-1]
print t[5:1:-2] print t[5:1:-2]
print t[5:1:-5] print t[5:1:-5]
print t[5:1] print t[5:1]
try:
t[None]
except TypeError as e:
print e
try:
t[(1, 2)]
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