mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-32571: Avoid raising unneeded AttributeError and silencing it in C code (GH-5222)
Add two new private APIs: _PyObject_LookupAttr() and _PyObject_LookupAttrId()
This commit is contained in:
parent
2b822a0bb1
commit
f320be77ff
22 changed files with 1455 additions and 1442 deletions
|
@ -1339,12 +1339,10 @@ deque_reduce(dequeobject *deque)
|
|||
PyObject *dict, *it;
|
||||
_Py_IDENTIFIER(__dict__);
|
||||
|
||||
dict = _PyObject_GetAttrId((PyObject *)deque, &PyId___dict__);
|
||||
if (_PyObject_LookupAttrId((PyObject *)deque, &PyId___dict__, &dict) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (dict == NULL) {
|
||||
if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
||||
return NULL;
|
||||
}
|
||||
PyErr_Clear();
|
||||
dict = Py_None;
|
||||
Py_INCREF(dict);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue