[Python-checkins] r73262 - python/branches/py3k/Modules/_io/textio.c
benjamin.peterson
python-checkins at python.org
Sat Jun 6 22:46:48 CEST 2009
Author: benjamin.peterson
Date: Sat Jun 6 22:46:48 2009
New Revision: 73262
Log:
stop throwing out all errors when PyObject_GetAttr fails
Modified:
python/branches/py3k/Modules/_io/textio.c
Modified: python/branches/py3k/Modules/_io/textio.c
==============================================================================
--- python/branches/py3k/Modules/_io/textio.c (original)
+++ python/branches/py3k/Modules/_io/textio.c Sat Jun 6 22:46:48 2009
@@ -988,8 +988,12 @@
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 @@
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 @@
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;
}
More information about the Python-checkins
mailing list