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:
Serhiy Storchaka 2018-01-25 10:49:40 +02:00 committed by INADA Naoki
parent 2b822a0bb1
commit f320be77ff
22 changed files with 1455 additions and 1442 deletions

View file

@ -1541,7 +1541,9 @@ _bufferedreader_read_all(buffered *self)
}
_bufferedreader_reset_buf(self);
readall = _PyObject_GetAttrWithoutError(self->raw, _PyIO_str_readall);
if (_PyObject_LookupAttr(self->raw, _PyIO_str_readall, &readall) < 0) {
goto cleanup;
}
if (readall) {
tmp = _PyObject_CallNoArg(readall);
Py_DECREF(readall);
@ -1561,9 +1563,6 @@ _bufferedreader_read_all(buffered *self)
}
goto cleanup;
}
else if (PyErr_Occurred()) {
goto cleanup;
}
chunks = PyList_New(0);
if (chunks == NULL)