summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-06-06 20:46:48 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-06-06 20:46:48 (GMT)
commit2cfca7977e42f6ec034ffe0782f2f1ad7d1efe7f (patch)
tree8a6cc4dc8aba7ece94afabbd772487fa3c6a3c80
parent0926ad1f05f06233a7595b9f837cc3c5ee5fe46d (diff)
downloadcpython-2cfca7977e42f6ec034ffe0782f2f1ad7d1efe7f.zip
cpython-2cfca7977e42f6ec034ffe0782f2f1ad7d1efe7f.tar.gz
cpython-2cfca7977e42f6ec034ffe0782f2f1ad7d1efe7f.tar.bz2
stop throwing out all errors when PyObject_GetAttr fails
-rw-r--r--Modules/_io/textio.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index 3ec8be6..220af8d 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -988,8 +988,12 @@ TextIOWrapper_init(PyTextIOWrapperObject *self, PyObject *args, PyObject *kwds)
goto error;
res = PyObject_GetAttrString(ci, "name");
Py_DECREF(ci);
- if (res == NULL)
- PyErr_Clear();
+ if (res == NULL) {
+ if (PyErr_ExceptionMatches(PyExc_AttributeError))
+ PyErr_Clear();
+ else
+ goto error;
+ }
else if (PyUnicode_Check(res)) {
encodefuncentry *e = encodefuncs;
while (e->name != NULL) {
@@ -1011,8 +1015,12 @@ TextIOWrapper_init(PyTextIOWrapperObject *self, PyObject *args, PyObject *kwds)
Py_TYPE(buffer) == &PyBufferedRandom_Type) {
raw = PyObject_GetAttrString(buffer, "raw");
/* Cache the raw FileIO object to speed up 'closed' checks */
- if (raw == NULL)
- PyErr_Clear();
+ if (raw == NULL) {
+ if (PyErr_ExceptionMatches(PyExc_AttributeError))
+ PyErr_Clear();
+ else
+ goto error;
+ }
else if (Py_TYPE(raw) == &PyFileIO_Type)
self->raw = raw;
else
@@ -2468,8 +2476,13 @@ TextIOWrapper_newlines_get(PyTextIOWrapperObject *self, void *context)
Py_RETURN_NONE;
res = PyObject_GetAttr(self->decoder, _PyIO_str_newlines);
if (res == NULL) {
- PyErr_Clear();
- Py_RETURN_NONE;
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_Clear();
+ Py_RETURN_NONE;
+ }
+ else {
+ return NULL;
+ }
}
return res;
}