From 12cd27b821d60a6610817c9a8128b8a938e55b96 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Wed, 11 Jan 2017 13:03:32 +0100 Subject: [PATCH] Amend 8ae8b443f: Handle comparison with None tokens. --- spacy/tokens/token.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spacy/tokens/token.pyx b/spacy/tokens/token.pyx index ff1c6149d..6202677f0 100644 --- a/spacy/tokens/token.pyx +++ b/spacy/tokens/token.pyx @@ -60,10 +60,10 @@ cdef class Token: def __repr__(self): return self.__str__() - def __richcmp__(self, other, int op): + def __richcmp__(self, Token other, int op): # http://cython.readthedocs.io/en/latest/src/userguide/special_methods.html my = self.idx - their = other.idx + their = other.idx if other is not None else None if op == 0: return my < their elif op == 2: