diff options
author | Jeroen Demeyer <J.Demeyer@UGent.be> | 2019-09-10 11:21:57 (GMT) |
---|---|---|
committer | T. Wouters <thomas@python.org> | 2019-09-10 11:21:57 (GMT) |
commit | 57ea33560662e0f20a3b0334bb20065771edf4da (patch) | |
tree | 5a8e4a23ec325a2a8ba6c121a123cd97339cbf06 /Objects/typeobject.c | |
parent | f958377b67c36a98d4df67b94c01eb29e3104f61 (diff) | |
download | cpython-57ea33560662e0f20a3b0334bb20065771edf4da.zip cpython-57ea33560662e0f20a3b0334bb20065771edf4da.tar.gz cpython-57ea33560662e0f20a3b0334bb20065771edf4da.tar.bz2 |
bpo-37619: update_one_slot() should not ignore wrapper descriptors for wrong type (GH-14836)
Diffstat (limited to 'Objects/typeobject.c')
-rw-r--r-- | Objects/typeobject.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 71d7f6f0..883bc22 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -7307,14 +7307,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 && |