Skip to content

Commit f161268

Browse files
committed
cleanup and clarification
1 parent 5c0a21c commit f161268

File tree

3 files changed

+242
-243
lines changed

3 files changed

+242
-243
lines changed

Objects/typeobject.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9357,17 +9357,17 @@ super_repr(PyObject *self)
93579357
su->type ? su->type->tp_name : "NULL");
93589358
}
93599359

9360+
// if `method` is non-NULL, we are looking for a method descriptor,
9361+
// and setting `*method` to 1 means we found one.
93609362
static PyObject *
93619363
do_super_lookup(superobject *su, PyTypeObject *su_type, PyObject *su_obj,
9362-
PyTypeObject *su_obj_type, PyObject *name, int *meth_found)
9364+
PyTypeObject *su_obj_type, PyObject *name, int *method)
93639365
{
9364-
PyTypeObject *starttype;
93659366
PyObject *mro, *res;
93669367
Py_ssize_t i, n;
93679368
int temp_su = 0;
93689369

9369-
starttype = su_obj_type;
9370-
if (starttype == NULL)
9370+
if (su_obj_type == NULL)
93719371
goto skip;
93729372

93739373
/* We want __class__ to return the class of the super object
@@ -9377,7 +9377,7 @@ do_super_lookup(superobject *su, PyTypeObject *su_type, PyObject *su_obj,
93779377
_PyUnicode_Equal(name, &_Py_ID(__class__)))
93789378
goto skip;
93799379

9380-
mro = starttype->tp_mro;
9380+
mro = su_obj_type->tp_mro;
93819381
if (mro == NULL)
93829382
goto skip;
93839383

@@ -9393,7 +9393,7 @@ do_super_lookup(superobject *su, PyTypeObject *su_type, PyObject *su_obj,
93939393
if (i >= n)
93949394
goto skip;
93959395

9396-
/* keep a strong reference to mro because starttype->tp_mro can be
9396+
/* keep a strong reference to mro because su_obj_type->tp_mro can be
93979397
replaced during PyDict_GetItemWithError(dict, name) */
93989398
Py_INCREF(mro);
93999399
do {
@@ -9404,8 +9404,8 @@ do_super_lookup(superobject *su, PyTypeObject *su_type, PyObject *su_obj,
94049404
res = PyDict_GetItemWithError(dict, name);
94059405
if (res != NULL) {
94069406
Py_INCREF(res);
9407-
if (meth_found && _PyType_HasFeature(Py_TYPE(res), Py_TPFLAGS_METHOD_DESCRIPTOR)) {
9408-
*meth_found = 1;
9407+
if (method && _PyType_HasFeature(Py_TYPE(res), Py_TPFLAGS_METHOD_DESCRIPTOR)) {
9408+
*method = 1;
94099409
}
94109410
else {
94119411
descrgetfunc f = Py_TYPE(res)->tp_descr_get;
@@ -9414,8 +9414,8 @@ do_super_lookup(superobject *su, PyTypeObject *su_type, PyObject *su_obj,
94149414
res2 = f(res,
94159415
/* Only pass 'obj' param if this is instance-mode super
94169416
(See SF ID #743627) */
9417-
(su_obj == (PyObject *)starttype) ? NULL : su_obj,
9418-
(PyObject *)starttype);
9417+
(su_obj == (PyObject *)su_obj_type) ? NULL : su_obj,
9418+
(PyObject *)su_obj_type);
94199419
Py_SETREF(res, res2);
94209420
}
94219421
}
@@ -9509,13 +9509,13 @@ supercheck(PyTypeObject *type, PyObject *obj)
95099509
}
95109510

95119511
PyObject *
9512-
_PySuper_Lookup(PyTypeObject *su_type, PyObject *su_obj, PyObject *name, int *meth_found)
9512+
_PySuper_Lookup(PyTypeObject *su_type, PyObject *su_obj, PyObject *name, int *method)
95139513
{
95149514
PyTypeObject *su_obj_type = supercheck(su_type, su_obj);
95159515
if (su_obj_type == NULL) {
95169516
return NULL;
95179517
}
9518-
PyObject *res = do_super_lookup(NULL, su_type, su_obj, su_obj_type, name, meth_found);
9518+
PyObject *res = do_super_lookup(NULL, su_type, su_obj, su_obj_type, name, method);
95199519
Py_DECREF(su_obj_type);
95209520
return res;
95219521
}

Python/bytecodes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,16 +1557,16 @@ dummy_func(
15571557
inst(LOAD_SUPER_ATTR, (global_super, class, self -- res2 if (oparg & 1), res)) {
15581558
PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2);
15591559
if (global_super == (PyObject *)&PySuper_Type && PyType_Check(class)) {
1560-
int meth_found = 0;
1560+
int method = 0;
15611561
Py_DECREF(global_super);
1562-
res = _PySuper_Lookup((PyTypeObject *)class, self, name, oparg & 1 ? &meth_found : NULL);
1562+
res = _PySuper_Lookup((PyTypeObject *)class, self, name, oparg & 1 ? &method : NULL);
15631563
Py_DECREF(class);
15641564
if (res == NULL) {
15651565
Py_DECREF(self);
15661566
ERROR_IF(true, error);
15671567
}
15681568
// Works with CALL, pushes two values: either `meth | self` or `NULL | meth`.
1569-
if (meth_found) {
1569+
if (method) {
15701570
res2 = res;
15711571
res = self; // transfer ownership
15721572
} else {

0 commit comments

Comments
 (0)