mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-31 16:07:41 +03:00 
			
		
		
		
	Fix Python 3 basestring error
This commit is contained in:
		
							parent
							
								
									276478fe0f
								
							
						
					
					
						commit
						b2d43b93d2
					
				|  | @ -110,11 +110,13 @@ cdef class StringStore: | ||||||
|                     return _decode(utf8str) |                     return _decode(utf8str) | ||||||
|                 else: |                 else: | ||||||
|                     raise IndexError(string_or_id) |                     raise IndexError(string_or_id) | ||||||
|         elif isinstance(string_or_id, basestring): |         else: | ||||||
|             if isinstance(string_or_id, bytes): |             if isinstance(string_or_id, bytes): | ||||||
|                 byte_string = <bytes>string_or_id |                 byte_string = <bytes>string_or_id | ||||||
|             else: |             elif isinstance(string_or_id, unicode): | ||||||
|                 byte_string = (<unicode>string_or_id).encode('utf8') |                 byte_string = (<unicode>string_or_id).encode('utf8') | ||||||
|  |             else: | ||||||
|  |                 raise TypeError(type(string_or_id)) | ||||||
|             utf8str = self._intern_utf8(byte_string, len(byte_string)) |             utf8str = self._intern_utf8(byte_string, len(byte_string)) | ||||||
|             if utf8str is NULL: |             if utf8str is NULL: | ||||||
|                 # TODO: We could get unlucky here, and hash into a value that |                 # 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)) |                 return _hash_utf8(byte_string, len(byte_string)) | ||||||
|             else: |             else: | ||||||
|                 return utf8str - self.c |                 return utf8str - self.c | ||||||
|         else: |  | ||||||
|             raise TypeError(type(string_or_id)) |  | ||||||
| 
 | 
 | ||||||
|     def __contains__(self, unicode string not None): |     def __contains__(self, unicode string not None): | ||||||
|         if len(string) == 0: |         if len(string) == 0: | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user