mirror of
https://github.com/python/cpython.git
synced 2025-09-25 01:43:11 +00:00
Merge
This commit is contained in:
commit
91fe8157fd
3 changed files with 12 additions and 1 deletions
|
@ -4247,6 +4247,14 @@ order (MRO) for bases """
|
||||||
with self.assertRaises(TypeError):
|
with self.assertRaises(TypeError):
|
||||||
str.__add__(fake_str, "abc")
|
str.__add__(fake_str, "abc")
|
||||||
|
|
||||||
|
def test_repr_as_str(self):
|
||||||
|
# Issue #11603: crash or infinite loop when rebinding __str__ as
|
||||||
|
# __repr__.
|
||||||
|
class Foo:
|
||||||
|
pass
|
||||||
|
Foo.__repr__ = Foo.__str__
|
||||||
|
foo = Foo()
|
||||||
|
str(foo)
|
||||||
|
|
||||||
class DictProxyTests(unittest.TestCase):
|
class DictProxyTests(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
|
@ -228,6 +228,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #11603: Fix a crash when __str__ is rebound as __repr__. Patch by
|
||||||
|
Andreas Stührk.
|
||||||
|
|
||||||
- Issue #11321: Fix a crash with multiple imports of the _pickle module when
|
- Issue #11321: Fix a crash with multiple imports of the _pickle module when
|
||||||
embedding Python. Patch by Andreas Stührk.
|
embedding Python. Patch by Andreas Stührk.
|
||||||
|
|
||||||
|
|
|
@ -2968,7 +2968,7 @@ object_str(PyObject *self)
|
||||||
unaryfunc f;
|
unaryfunc f;
|
||||||
|
|
||||||
f = Py_TYPE(self)->tp_repr;
|
f = Py_TYPE(self)->tp_repr;
|
||||||
if (f == NULL)
|
if (f == NULL || f == object_str)
|
||||||
f = object_repr;
|
f = object_repr;
|
||||||
return f(self);
|
return f(self);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue