From b2d43b93d2182ab57b98274cd4b4ad4df2570fd6 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 24 Oct 2016 14:22:51 +0200 Subject: [PATCH] Fix Python 3 basestring error --- spacy/strings.pyx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spacy/strings.pyx b/spacy/strings.pyx index 02eed4d2f..170fb2796 100644 --- a/spacy/strings.pyx +++ b/spacy/strings.pyx @@ -110,11 +110,13 @@ cdef class StringStore: return _decode(utf8str) else: raise IndexError(string_or_id) - elif isinstance(string_or_id, basestring): + else: if isinstance(string_or_id, bytes): byte_string = string_or_id - else: + elif isinstance(string_or_id, unicode): byte_string = (string_or_id).encode('utf8') + else: + raise TypeError(type(string_or_id)) utf8str = self._intern_utf8(byte_string, len(byte_string)) if utf8str is NULL: # TODO: We could get unlucky here, and hash into a value that @@ -123,8 +125,6 @@ cdef class StringStore: return _hash_utf8(byte_string, len(byte_string)) else: return utf8str - self.c - else: - raise TypeError(type(string_or_id)) def __contains__(self, unicode string not None): if len(string) == 0: