[pypy-svn] r36080 - in pypy/dist/pypy/objspace/std: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Sun Dec 31 17:31:33 CET 2006
Author: cfbolz
Date: Sun Dec 31 17:31:33 2006
New Revision: 36080
Modified:
pypy/dist/pypy/objspace/std/dictmultiobject.py
pypy/dist/pypy/objspace/std/test/test_dictmultiobject.py
Log:
test + bug fix: the result of <instance>.__dict__.values could be mutated to
change <instance> when using sharing dicts.
Modified: pypy/dist/pypy/objspace/std/dictmultiobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/dictmultiobject.py (original)
+++ pypy/dist/pypy/objspace/std/dictmultiobject.py Sun Dec 31 17:31:33 2006
@@ -574,7 +574,7 @@
if item >= 0]
def values(self):
- return self.entries
+ return self.entries[:]
def items(self):
space = self.space
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 Sun Dec 31 17:31:33 2006
@@ -22,6 +22,16 @@
def setup_class(cls):
cls.space = gettestobjspace(**{"objspace.std.withsharingdict": True})
+ def test_values_does_not_share(self):
+ class A(object):
+ pass
+ a = A()
+ a.abc = 12
+ l = a.__dict__.values()
+ assert l == [12]
+ l[0] = 24
+ assert a.abc == 12
+
class FakeSpace(test_dictobject.FakeSpace):
def str_w(self, string):
More information about the Pypy-commit
mailing list