Mercurial > cpython-lru_cache-weakref
diff Python/pythonrun.c @ 76085:ff7587546a1d
merge 3.2
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Tue, 03 Apr 2012 00:35:36 -0400 |
| parents | b299c4f31ff2 43606a4085b0 |
| children | 2dd046be2c88 |
line wrap: on
line diff
--- a/Python/pythonrun.c Mon Apr 02 14:25:55 2012 -0400 +++ b/Python/pythonrun.c Tue Apr 03 00:35:36 2012 -0400 @@ -1356,56 +1356,67 @@ _Py_IDENTIFIER(offset); _Py_IDENTIFIER(text); - /* new style errors. `err' is an instance */ - - if (! (v = _PyObject_GetAttrId(err, &PyId_msg))) - goto finally; - *message = v; + *message = NULL; - if (!(v = _PyObject_GetAttrId(err, &PyId_filename))) - goto finally; - if (v == Py_None) - *filename = NULL; - else if (! (*filename = _PyUnicode_AsString(v))) + /* new style errors. `err' is an instance */ + *message = _PyObject_GetAttrId(err, &PyId_msg); + if (!*message) goto finally; - Py_DECREF(v); - if (!(v = _PyObject_GetAttrId(err, &PyId_lineno))) + v = _PyObject_GetAttrId(err, &PyId_filename); + if (!v) + goto finally; + if (v == Py_None) { + Py_DECREF(v); + *filename = NULL; + } + else { + *filename = _PyUnicode_AsString(v); + Py_DECREF(v); + if (!*filename) + goto finally; + } + + v = _PyObject_GetAttrId(err, &PyId_lineno); + if (!v) goto finally; hold = PyLong_AsLong(v); Py_DECREF(v); - v = NULL; if (hold < 0 && PyErr_Occurred()) goto finally; *lineno = (int)hold; - if (!(v = _PyObject_GetAttrId(err, &PyId_offset))) + v = _PyObject_GetAttrId(err, &PyId_offset); + if (!v) goto finally; if (v == Py_None) { *offset = -1; Py_DECREF(v); - v = NULL; } else { hold = PyLong_AsLong(v); Py_DECREF(v); - v = NULL; if (hold < 0 && PyErr_Occurred()) goto finally; *offset = (int)hold; } - if (!(v = _PyObject_GetAttrId(err, &PyId_text))) + v = _PyObject_GetAttrId(err, &PyId_text); + if (!v) goto finally; - if (v == Py_None) + if (v == Py_None) { + Py_DECREF(v); *text = NULL; - else if (!PyUnicode_Check(v) || - !(*text = _PyUnicode_AsString(v))) - goto finally; - Py_DECREF(v); + } + else { + *text = _PyUnicode_AsString(v); + Py_DECREF(v); + if (!*text) + goto finally; + } return 1; finally: - Py_XDECREF(v); + Py_XDECREF(*message); return 0; }
