mirror of https://github.com/python/cpython
Simplify calling.
This commit is contained in:
parent
a89dbec257
commit
e4e023c4d3
|
@ -1072,21 +1072,15 @@ static PyMappingMethods instance_as_mapping = {
|
||||||
static PyObject *
|
static PyObject *
|
||||||
instance_item(PyInstanceObject *inst, Py_ssize_t i)
|
instance_item(PyInstanceObject *inst, Py_ssize_t i)
|
||||||
{
|
{
|
||||||
PyObject *func, *arg, *res;
|
PyObject *func, *res;
|
||||||
|
|
||||||
if (getitemstr == NULL)
|
if (getitemstr == NULL)
|
||||||
getitemstr = PyString_InternFromString("__getitem__");
|
getitemstr = PyString_InternFromString("__getitem__");
|
||||||
func = instance_getattr(inst, getitemstr);
|
func = instance_getattr(inst, getitemstr);
|
||||||
if (func == NULL)
|
if (func == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
arg = Py_BuildValue("(n)", i);
|
res = PyObject_CallFunction(func, "n", i);
|
||||||
if (arg == NULL) {
|
|
||||||
Py_DECREF(func);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
res = PyEval_CallObject(func, arg);
|
|
||||||
Py_DECREF(func);
|
Py_DECREF(func);
|
||||||
Py_DECREF(arg);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue