Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit caf5904

Browse files
committed
slot_sq_item(): ensure that self is an instance of the wrapper's
d_type before calling the wrapped function. fixup_slot_dispatchers(): fix indentation.
1 parent bcbdc95 commit caf5904

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Objects/typeobject.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2908,7 +2908,8 @@ slot_sq_item(PyObject *self, int i)
29082908
if (func->ob_type == &PyWrapperDescr_Type) {
29092909
PyWrapperDescrObject *wrapper =
29102910
(PyWrapperDescrObject *)func;
2911-
if (wrapper->d_base->wrapper == wrap_sq_item) {
2911+
if (wrapper->d_base->wrapper == wrap_sq_item &&
2912+
PyType_IsSubtype(self->ob_type, wrapper->d_type)) {
29122913
intargfunc f;
29132914
f = (intargfunc)(wrapper->d_wrapped);
29142915
return f(self, i);
@@ -3938,9 +3939,10 @@ fixup_slot_dispatchers(PyTypeObject *type)
39383939
if (descr->ob_type == &PyWrapperDescr_Type) {
39393940
d = (PyWrapperDescrObject *)descr;
39403941
if (d->d_base->wrapper == p->wrapper &&
3941-
PyType_IsSubtype(type, d->d_type)) {
3942+
PyType_IsSubtype(type, d->d_type))
3943+
{
39423944
if (specific == NULL ||
3943-
specific == d->d_wrapped)
3945+
specific == d->d_wrapped)
39443946
specific = d->d_wrapped;
39453947
else
39463948
use_generic = 1;

0 commit comments

Comments
 (0)