[pypy-svn] r55041 - pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk

cfbolz at codespeak.net cfbolz at codespeak.net
Tue May 20 20:55:37 CEST 2008


Author: cfbolz
Date: Tue May 20 20:55:36 2008
New Revision: 55041

Modified:
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/model.py
Log:
fix __eq__ and add __hash__


Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/model.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/model.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/model.py	Tue May 20 20:55:36 2008
@@ -125,11 +125,16 @@
         return self.value == other.value
 
     def __eq__(self, other):
+        if not isinstance(other, W_SmallInteger):
+            return False
         return self.value == other.value
 
     def __ne__(self, other):
         return not self == other
 
+    def __hash__(self):
+        return self.value
+
 
 class W_Float(W_Object):
     """Boxed float value."""
@@ -157,11 +162,16 @@
         return self.value == other.value
 
     def __eq__(self, other):
+        if not isinstance(other, W_Float):
+            return False
         return self.value == other.value
 
     def __ne__(self, other):
         return not self == other
 
+    def __hash__(self):
+        return hash(self.value)
+
 class W_AbstractObjectWithIdentityHash(W_Object):
     """Object with explicit hash (ie all except small
     ints and floats)."""



More information about the Pypy-commit mailing list