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

Fix Str.__getitem__

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