@@ -155,23 +155,21 @@ def __eq__(self, other):
155155 other_attr = other .microsecond
156156 if attr is not None and attr != other_attr :
157157 result = False
158+
158159 except AttributeError :
159- result = NotImplemented
160+ result = other .__eq__ (self )
161+ if result is NotImplemented :
162+ # Equality is undefined between these objects. We don't
163+ # want Python to fall back to the default `object`
164+ # behaviour (which compares using object IDs), so we raise
165+ # an exception here instead.
166+ fmt = "unable to compare PartialDateTime with {}"
167+ raise TypeError (fmt .format (type (other )))
168+
160169 return result
161170
162171 def __ne__ (self , other ):
163172 result = self .__eq__ (other )
164173 if result is not NotImplemented :
165174 result = not result
166175 return result
167-
168- def __cmp__ (self , other ):
169- # Since we've defined all the rich comparison operators (via
170- # functools.total_ordering), we can only reach this point if
171- # neither this class nor the other class had a rich comparison
172- # that could handle the type combination.
173- # We don't want Python to fall back to the default `object`
174- # behaviour (which compares using object IDs), so we raise an
175- # exception here instead.
176- fmt = "unable to compare PartialDateTime with {}"
177- raise TypeError (fmt .format (type (other )))
0 commit comments