Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ugrapheme/ugrapheme.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,13 @@ cpdef unicode grapheme_slice(unicode ustr,

cdef size_t l = PyUnicode_GetLength(ustr) - upos
if startpos < 0:
startpos = 0
startpos += l
if startpos < 0:
startpos = 0
if endpos < 0:
endpos += l
if endpos < 0:
endpos = 0
if startpos >= l or endpos <= startpos:
return ''

Expand Down