mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +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
|
|
@ -830,17 +830,15 @@ tee(PyObject *self, PyObject *args)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
copyfunc = _PyObject_GetAttrId(it, &PyId___copy__);
|
||||
if (copyfunc != NULL) {
|
||||
copyable = it;
|
||||
}
|
||||
else if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
||||
if (_PyObject_LookupAttrId(it, &PyId___copy__, ©func) < 0) {
|
||||
Py_DECREF(it);
|
||||
Py_DECREF(result);
|
||||
return NULL;
|
||||
}
|
||||
if (copyfunc != NULL) {
|
||||
copyable = it;
|
||||
}
|
||||
else {
|
||||
PyErr_Clear();
|
||||
copyable = tee_fromiterable(it);
|
||||
Py_DECREF(it);
|
||||
if (copyable == NULL) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue