Mercurial > cpython-lru_cache-weakref
comparison Python/bltinmodule.c @ 20471:bbdc0abfbb13 legacy-trunk
SF patch #471852 (anonymous) notes that getattr(obj, name, default)
masks any exception, not just AttributeError. Fix this.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 16 Oct 2001 21:31:32 +0000 |
| parents | aa681345bfab |
| children | edd9d0b3c47e |
comparison
equal
deleted
inserted
replaced
| 20470:8964ef84c92f | 20471:bbdc0abfbb13 |
|---|---|
| 617 PyErr_SetString(PyExc_TypeError, | 617 PyErr_SetString(PyExc_TypeError, |
| 618 "attribute name must be string"); | 618 "attribute name must be string"); |
| 619 return NULL; | 619 return NULL; |
| 620 } | 620 } |
| 621 result = PyObject_GetAttr(v, name); | 621 result = PyObject_GetAttr(v, name); |
| 622 if (result == NULL && dflt != NULL) { | 622 if (result == NULL && dflt != NULL && |
| 623 PyErr_ExceptionMatches(PyExc_AttributeError)) | |
| 624 { | |
| 623 PyErr_Clear(); | 625 PyErr_Clear(); |
| 624 Py_INCREF(dflt); | 626 Py_INCREF(dflt); |
| 625 result = dflt; | 627 result = dflt; |
| 626 } | 628 } |
| 627 return result; | 629 return result; |
