diff --git a/spacy/utf8string.pxd b/spacy/utf8string.pxd index 6bd5c6757..5ef4113d5 100644 --- a/spacy/utf8string.pxd +++ b/spacy/utf8string.pxd @@ -31,4 +31,4 @@ cdef class StringStore: cdef int size cdef int _resize_at - cdef Utf8Str* intern(self, char* chars, int length) except NULL + cdef const Utf8Str* intern(self, char* chars, int length) except NULL diff --git a/spacy/utf8string.pyx b/spacy/utf8string.pyx index 0384a150c..1d2b7a264 100644 --- a/spacy/utf8string.pyx +++ b/spacy/utf8string.pyx @@ -20,7 +20,7 @@ cdef class StringStore: def __getitem__(self, object string_or_id): cdef bytes byte_string - cdef Utf8Str* utf8str + cdef const Utf8Str* utf8str if isinstance(string_or_id, int) or isinstance(string_or_id, long): if string_or_id < 1 or string_or_id >= self.size: raise IndexError(string_or_id) @@ -36,7 +36,7 @@ cdef class StringStore: else: raise TypeError(type(string_or_id)) - cdef Utf8Str* intern(self, char* chars, int length) except NULL: + cdef const Utf8Str* intern(self, char* chars, int length) except NULL: # 0 means missing, but we don't bother offsetting the index. We waste # slot 0 to simplify the code, because it doesn't matter. assert length != 0