summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-04-24 15:06:25 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-04-24 15:06:25 (GMT)
commit7b1668735ace947474bb94f812c03b39bd963a77 (patch)
tree1b5858e50db5decab64c00ccd4300d412172eea1 /Lib/test/test_descr.py
parent790e005669912adcbe81073284c982a5b844d2d3 (diff)
downloadcpython-7b1668735ace947474bb94f812c03b39bd963a77.zip
cpython-7b1668735ace947474bb94f812c03b39bd963a77.tar.gz
cpython-7b1668735ace947474bb94f812c03b39bd963a77.tar.bz2
don't use a slot wrapper from a different special method (closes #14658)
This also alters the fix to #11603. Specifically, setting __repr__ to object.__str__ now raises a recursion RuntimeError when str() or repr() is called instead of silently bypassing the recursion. I believe this behavior is more correct.
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 141d791..2289f6e 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -4430,7 +4430,15 @@ order (MRO) for bases """
pass
Foo.__repr__ = Foo.__str__
foo = Foo()
- str(foo)
+ self.assertRaises(RuntimeError, str, foo)
+ self.assertRaises(RuntimeError, repr, foo)
+
+ def test_mixing_slot_wrappers(self):
+ class X(dict):
+ __setattr__ = dict.__setitem__
+ x = X()
+ x.y = 42
+ self.assertEqual(x["y"], 42)
def test_cycle_through_dict(self):
# See bug #1469629