Commit 0d3108ce authored by Xavier Thompson's avatar Xavier Thompson

Fix Str.__getitem__

parent 8520b76d
......@@ -43,14 +43,12 @@ cdef cypclass Str "Cy_Str":
char __getitem__(self, int index) except 0:
cdef int end = self._str.size()
cdef int idx = index
if index < 0:
index = -index
idx = end - index
if index >= end:
with gil:
raise ValueError('index out of range')
return self._str[idx]
index = end + index
if 0 <= index < end:
return self._str[index]
with gil:
raise ValueError('index out of range')
int find(self, Str s, size_t start=0, size_t stop=0):
if start < stop and stop <= self._str.size():
......
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