mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
refactor and avoid warnings
This commit is contained in:
parent
8c43e69bce
commit
74529ad3f4
1 changed files with 5 additions and 7 deletions
|
@ -1152,13 +1152,11 @@ _PyObject_GenericSetAttrWithDict(PyObject *obj, PyObject *name,
|
||||||
name->ob_type->tp_name);
|
name->ob_type->tp_name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Py_INCREF(name);
|
|
||||||
|
|
||||||
if (tp->tp_dict == NULL) {
|
if (tp->tp_dict == NULL && PyType_Ready(tp) < 0)
|
||||||
if (PyType_Ready(tp) < 0)
|
return -1;
|
||||||
goto done;
|
|
||||||
}
|
Py_INCREF(name);
|
||||||
|
|
||||||
descr = _PyType_Lookup(tp, name);
|
descr = _PyType_Lookup(tp, name);
|
||||||
Py_XINCREF(descr);
|
Py_XINCREF(descr);
|
||||||
|
@ -1190,9 +1188,9 @@ _PyObject_GenericSetAttrWithDict(PyObject *obj, PyObject *name,
|
||||||
res = PyDict_DelItem(dict, name);
|
res = PyDict_DelItem(dict, name);
|
||||||
else
|
else
|
||||||
res = PyDict_SetItem(dict, name, value);
|
res = PyDict_SetItem(dict, name, value);
|
||||||
|
Py_DECREF(dict);
|
||||||
if (res < 0 && PyErr_ExceptionMatches(PyExc_KeyError))
|
if (res < 0 && PyErr_ExceptionMatches(PyExc_KeyError))
|
||||||
PyErr_SetObject(PyExc_AttributeError, name);
|
PyErr_SetObject(PyExc_AttributeError, name);
|
||||||
Py_DECREF(dict);
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue