diff --git a/spacy/lang.pyx b/spacy/lang.pyx index 8d4ea7802..9013de9d0 100644 --- a/spacy/lang.pyx +++ b/spacy/lang.pyx @@ -296,8 +296,10 @@ cdef class Lexicon: def __setitem__(self, unicode uni_string, dict props): cdef UniStr s slice_unicode(&s, uni_string, 0, len(uni_string)) - cdef const Lexeme* lex = self.get(&s) - self.lexemes[lex.id][0] = lexeme_init(lex.id, s.chars[:s.n], s.key, self.strings, props) + # Cast through the const here, since we're allowed to change our own + # Lexemes. + lex = self.get(&s) + lex[0] = lexeme_init(lex.id, s.chars[:s.n], s.key, self.strings, props) def dump(self, loc): if path.exists(loc):