Issue #11603: Fix a crash when __str__ is rebound as __repr__.
Patch by Andreas Stührk.
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index b5d9890..964cc5c 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -4581,6 +4581,14 @@
with self.assertRaises(TypeError):
str.__add__(fake_str, "abc")
+ def test_repr_as_str(self):
+ # Issue #11603: crash or infinite loop when rebinding __str__ as
+ # __repr__.
+ class Foo(object):
+ pass
+ Foo.__repr__ = Foo.__str__
+ foo = Foo()
+ str(foo)
class DictProxyTests(unittest.TestCase):
def setUp(self):