diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-04-24 15:06:25 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-04-24 15:06:25 (GMT) |
commit | d157a4c3dd49728b95fe63b2ff931da5bec5fe75 (patch) | |
tree | 31c2f6c085d7eba1eda2b52a20c0f5e9fc06b02c /Objects | |
parent | e65753e09e9b8a383b68b71f7e39d597b0c61b68 (diff) | |
download | cpython-d157a4c3dd49728b95fe63b2ff931da5bec5fe75.zip cpython-d157a4c3dd49728b95fe63b2ff931da5bec5fe75.tar.gz cpython-d157a4c3dd49728b95fe63b2ff931da5bec5fe75.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 'Objects')
-rw-r--r-- | Objects/typeobject.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 877bcb7..08e5775 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2996,7 +2996,7 @@ object_str(PyObject *self) unaryfunc f; f = Py_TYPE(self)->tp_repr; - if (f == NULL || f == object_str) + if (f == NULL) f = object_repr; return f(self); } @@ -6143,7 +6143,8 @@ update_one_slot(PyTypeObject *type, slotdef *p) } continue; } - if (Py_TYPE(descr) == &PyWrapperDescr_Type) { + if (Py_TYPE(descr) == &PyWrapperDescr_Type && + ((PyWrapperDescrObject *)descr)->d_base->name_strobj == p->name_strobj) { void **tptr = resolve_slotdups(type, p->name_strobj); if (tptr == NULL || tptr == ptr) generic = p->function; |