cpython: 2d2bc1906b5b (original) (raw)
Mercurial > cpython
changeset 102774:2d2bc1906b5b
Issue #27128: Cleanup slot_sq_item() * Invert condition of test to avoid levels of indentation * Remove useless Py_XDECREF(args) in the error block * Replace Py_XDECREF(func) with Py_DECREF(func) in the error block: func cannot be NULL when reaching the error block [#27128]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Fri, 19 Aug 2016 18:17:37 +0200 |
parents | 8e085070ab28 |
children | 6eb586b85fa1 |
files | Objects/typeobject.c |
diffstat | 1 files changed, 34 insertions(+), 26 deletions(-)[+] [-] Objects/typeobject.c 60 |
line wrap: on
line diff
--- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -5808,38 +5808,46 @@ slot_sq_length(PyObject *self) static PyObject * slot_sq_item(PyObject *self, Py_ssize_t i) {
- PyObject *func, *ival = NULL, *args, *retval = NULL; descrgetfunc f; func = PyType_LookupId(Py_TYPE(self), &PyId___getitem_);
- if (func != NULL) {
if ((f = Py_TYPE(func)->tp_descr_get) == NULL)[](#l1.13)
Py_INCREF(func);[](#l1.14)
else {[](#l1.15)
func = f(func, self, (PyObject *)(Py_TYPE(self)));[](#l1.16)
if (func == NULL) {[](#l1.17)
return NULL;[](#l1.18)
}[](#l1.19)
}[](#l1.20)
ival = PyLong_FromSsize_t(i);[](#l1.21)
if (ival != NULL) {[](#l1.22)
args = PyTuple_New(1);[](#l1.23)
if (args != NULL) {[](#l1.24)
PyTuple_SET_ITEM(args, 0, ival);[](#l1.25)
retval = PyObject_Call(func, args, NULL);[](#l1.26)
Py_DECREF(args);[](#l1.27)
Py_DECREF(func);[](#l1.28)
return retval;[](#l1.29)
}[](#l1.30)
}[](#l1.31)
- if (func == NULL) {
PyObject *getitem_str = _PyUnicode_FromId(&PyId___getitem__);[](#l1.33)
PyErr_SetObject(PyExc_AttributeError, getitem_str);[](#l1.34)
return NULL;[](#l1.35)
- }
PyObject *getitem_str = _PyUnicode_FromId(&PyId___getitem__);[](#l1.43)
PyErr_SetObject(PyExc_AttributeError, getitem_str);[](#l1.44)
- }
- Py_XDECREF(args);
func = f(func, self, (PyObject *)(Py_TYPE(self)));[](#l1.47)
if (func == NULL) {[](#l1.48)
return NULL;[](#l1.49)
}[](#l1.50)
- }