Author: Armin Rigo <[email protected]>
Branch:
Changeset: r45315:afeebea4b340
Date: 2011-07-03 11:43 +0200
http://bitbucket.org/pypy/pypy/changeset/afeebea4b340/
Log: merge heads
diff --git a/pypy/objspace/std/dictmultiobject.py
b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -163,10 +163,7 @@
elif self.space.is_w(self.space.type(w_key), self.space.w_int):
self.switch_to_int_strategy(w_dict)
else:
- strategy = self.space.fromcache(ObjectDictStrategy)
- storage = strategy.get_empty_storage()
- w_dict.strategy = strategy
- w_dict.dstorage = storage
+ self.switch_to_object_strategy(w_dict)
def switch_to_string_strategy(self, w_dict):
strategy = self.space.fromcache(StringDictStrategy)
@@ -180,6 +177,12 @@
w_dict.strategy = strategy
w_dict.dstorage = storage
+ def switch_to_object_strategy(self, w_dict):
+ strategy = self.space.fromcache(ObjectDictStrategy)
+ storage = strategy.get_empty_storage()
+ w_dict.strategy = strategy
+ w_dict.dstorage = storage
+
def getitem(self, w_dict, w_key):
#return w_value or None
# in case the key is unhashable, try to hash it
diff --git a/pypy/objspace/std/test/test_mapdict.py
b/pypy/objspace/std/test/test_mapdict.py
--- a/pypy/objspace/std/test/test_mapdict.py
+++ b/pypy/objspace/std/test/test_mapdict.py
@@ -622,6 +622,14 @@
assert a.__dict__ is d
assert isinstance(a, B)
+ def test_setdict(self):
+ class A(object):
+ pass
+
+ a = A()
+ a.__dict__ = {}
+ a.__dict__ = {}
+
class AppTestWithMapDictAndCounters(object):
def setup_class(cls):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit