Bug fix in Rectangle.__eq__: Handle comparison with unsubscriptable object
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 29 Jan 2006 19:04:10 +0000 (19:04 +0000)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 29 Jan 2006 19:04:10 +0000 (19:04 +0000)
correctly.

src/packages/kofoto/rectangle.py

index b55c944..3c78767 100644 (file)
@@ -45,7 +45,10 @@ class Rectangle:
         return self.__class__(self._width / factor, self._height / factor)
 
     def __eq__(self, other):
-        return self._width == other[0] and self._height == other[1]
+        try:
+            return self._width == other[0] and self._height == other[1]
+        except (TypeError, IndexError):
+            return False
 
     def __ne__(self, other):
         return not (self == other)