summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-09-10 12:55:12 (GMT)
committerT. Wouters <thomas@python.org>2019-09-10 12:55:12 (GMT)
commiteb1bc48c74f4f8af88b5276729f9652201e46324 (patch)
treefefb8cb5f66fcf1da6602fd72047d23056dc40ca /Objects
parent55daf1a56163e0673654712bb92ce47a9b6f7be3 (diff)
downloadcpython-eb1bc48c74f4f8af88b5276729f9652201e46324.zip
cpython-eb1bc48c74f4f8af88b5276729f9652201e46324.tar.gz
cpython-eb1bc48c74f4f8af88b5276729f9652201e46324.tar.bz2
bpo-37619: update_one_slot() should not ignore wrapper descriptors for wrong type (GH-15838)
(cherry picked from commit 57ea33560662e0f20a3b0334bb20065771edf4da) Co-authored-by: Jeroen Demeyer <J.Demeyer@UGent.be>
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 8ece218..f42caed 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -7243,14 +7243,21 @@ update_one_slot(PyTypeObject *type, slotdef *p)
if (tptr == NULL || tptr == ptr)
generic = p->function;
d = (PyWrapperDescrObject *)descr;
- if (d->d_base->wrapper == p->wrapper &&
+ if ((specific == NULL || specific == d->d_wrapped) &&
+ d->d_base->wrapper == p->wrapper &&
PyType_IsSubtype(type, PyDescr_TYPE(d)))
{
- if (specific == NULL ||
- specific == d->d_wrapped)
- specific = d->d_wrapped;
- else
- use_generic = 1;
+ specific = d->d_wrapped;
+ }
+ else {
+ /* We cannot use the specific slot function because either
+ - it is not unique: there are multiple methods for this
+ slot and they conflict
+ - the signature is wrong (as checked by the ->wrapper
+ comparison above)
+ - it's wrapping the wrong class
+ */
+ use_generic = 1;
}
}
else if (Py_TYPE(descr) == &PyCFunction_Type &&