[pypy-svn] r44577 - in pypy/dist/pypy/objspace/std: . test

fijal at codespeak.net fijal at codespeak.net
Thu Jun 28 10:38:17 CEST 2007


Author: fijal
Date: Thu Jun 28 10:38:17 2007
New Revision: 44577

Modified:
   pypy/dist/pypy/objspace/std/dictmultiobject.py
   pypy/dist/pypy/objspace/std/test/test_dictmultiobject.py
Log:
Fix a funny bug in empty dict impl (!!!!)


Modified: pypy/dist/pypy/objspace/std/dictmultiobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/dictmultiobject.py	(original)
+++ pypy/dist/pypy/objspace/std/dictmultiobject.py	Thu Jun 28 10:38:17 2007
@@ -148,6 +148,10 @@
         self.space = space
 
     def get(self, w_lookup):
+        space = self.space
+        if not _is_str(space, w_lookup) and not _is_sane_hash(space, w_lookup):
+            # count hash
+            space.hash(w_lookup)
         return None
 
     def setitem(self, w_key, w_value):
@@ -165,7 +169,12 @@
     def setitem_str(self, w_key, w_value, shadows_type=True):
         return StrDictImplementation(self.space).setitem_str(w_key, w_value)
         #return SmallStrDictImplementation(self.space, w_key, w_value)
+
     def delitem(self, w_key):
+        space = self.space
+        if not _is_str(space, w_key) and not _is_sane_hash(space, w_key):
+            # count hash
+            space.hash(w_key)
         raise KeyError
     
     def length(self):

Modified: pypy/dist/pypy/objspace/std/test/test_dictmultiobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_dictmultiobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_dictmultiobject.py	Thu Jun 28 10:38:17 2007
@@ -28,6 +28,10 @@
         raises(StopIteration, i.next)
         raises(StopIteration, i.next)
 
+    def test_emptydict_unhashable(self):
+        raises(TypeError, "{}[['x']]")
+
+
 class TestW_DictSharing(test_dictobject.TestW_DictObject):
     def setup_class(cls):
         cls.space = gettestobjspace(**{"objspace.std.withsharingdict": True})



More information about the Pypy-commit mailing list