mirror of
https://github.com/python/cpython.git
synced 2025-10-15 03:10:29 +00:00
stop throwing out all errors when PyObject_GetAttr fails
This commit is contained in:
parent
0926ad1f05
commit
2cfca7977e
1 changed files with 19 additions and 6 deletions
|
@ -988,8 +988,12 @@ TextIOWrapper_init(PyTextIOWrapperObject *self, PyObject *args, PyObject *kwds)
|
||||||
goto error;
|
goto error;
|
||||||
res = PyObject_GetAttrString(ci, "name");
|
res = PyObject_GetAttrString(ci, "name");
|
||||||
Py_DECREF(ci);
|
Py_DECREF(ci);
|
||||||
if (res == NULL)
|
if (res == NULL) {
|
||||||
|
if (PyErr_ExceptionMatches(PyExc_AttributeError))
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
|
else
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
else if (PyUnicode_Check(res)) {
|
else if (PyUnicode_Check(res)) {
|
||||||
encodefuncentry *e = encodefuncs;
|
encodefuncentry *e = encodefuncs;
|
||||||
while (e->name != NULL) {
|
while (e->name != NULL) {
|
||||||
|
@ -1011,8 +1015,12 @@ TextIOWrapper_init(PyTextIOWrapperObject *self, PyObject *args, PyObject *kwds)
|
||||||
Py_TYPE(buffer) == &PyBufferedRandom_Type) {
|
Py_TYPE(buffer) == &PyBufferedRandom_Type) {
|
||||||
raw = PyObject_GetAttrString(buffer, "raw");
|
raw = PyObject_GetAttrString(buffer, "raw");
|
||||||
/* Cache the raw FileIO object to speed up 'closed' checks */
|
/* Cache the raw FileIO object to speed up 'closed' checks */
|
||||||
if (raw == NULL)
|
if (raw == NULL) {
|
||||||
|
if (PyErr_ExceptionMatches(PyExc_AttributeError))
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
|
else
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
else if (Py_TYPE(raw) == &PyFileIO_Type)
|
else if (Py_TYPE(raw) == &PyFileIO_Type)
|
||||||
self->raw = raw;
|
self->raw = raw;
|
||||||
else
|
else
|
||||||
|
@ -2468,9 +2476,14 @@ TextIOWrapper_newlines_get(PyTextIOWrapperObject *self, void *context)
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
res = PyObject_GetAttr(self->decoder, _PyIO_str_newlines);
|
res = PyObject_GetAttr(self->decoder, _PyIO_str_newlines);
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
|
if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue