mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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.
This commit is contained in:
parent
790e005669
commit
7b1668735a
3 changed files with 18 additions and 3 deletions
|
@ -2928,7 +2928,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);
|
||||
}
|
||||
|
@ -5757,7 +5757,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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue