[pypy-commit] pypy set-strategies: Altough the if-part will never be executed in IntegerSetStrategy, the annotator doesn't know what type d is. It could be an int-dict and then d[w_key], where w_key is always a wrapped object because of the getkeys()-method, would degenerate this object to an integer.

l.diekmann noreply at buildbot.pypy.org
Thu Nov 10 13:50:10 CET 2011


Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: set-strategies
Changeset: r49181:95966fc24e8c
Date: 2011-05-27 11:53 +0200
http://bitbucket.org/pypy/pypy/changeset/95966fc24e8c/

Log:	Altough the if-part will never be executed in IntegerSetStrategy,
	the annotator doesn't know what type d is. It could be an int-dict
	and then d[w_key], where w_key is always a wrapped object because of
	the getkeys()-method, would degenerate this object to an integer.

diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -539,18 +539,19 @@
         return True
 
     def update(self, w_set, w_other):
-        d = self.cast_from_void_star(w_set.sstorage)
         if w_set.strategy is self.space.fromcache(ObjectSetStrategy):
+            d_obj = self.cast_from_void_star(w_set.sstorage)
             other_w = w_other.getkeys()
-            #XXX better solution!?
             for w_key in other_w:
-                d[w_key] = None
+                d_obj[w_key] = None
             return
 
         elif w_set.strategy is w_other.strategy:
+            d_int = self.cast_from_void_star(w_set.sstorage)
             other = self.cast_from_void_star(w_other.sstorage)
-            d.update(other)
+            d_int.update(other)
             return
+
         w_set.switch_to_object_strategy(self.space)
         w_set.update(w_other)
 


More information about the pypy-commit mailing list