diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-04-03 04:35:36 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-04-03 04:35:36 (GMT) |
commit | 0a9a6363025ba16b1c2041a05e6f33ee408b1bda (patch) | |
tree | 3634dc8b9c4d87add546515afc34d6c12ee9c2b7 /Python/pythonrun.c | |
parent | cbb290af08bc97ace72ca1a5ae19fd7375cae938 (diff) | |
parent | 80d50428ce7697cc2f1fdb4370800b89399c4cda (diff) | |
download | cpython-0a9a6363025ba16b1c2041a05e6f33ee408b1bda.zip cpython-0a9a6363025ba16b1c2041a05e6f33ee408b1bda.tar.gz cpython-0a9a6363025ba16b1c2041a05e6f33ee408b1bda.tar.bz2 |
merge 3.2
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index f4e7e7b..b68bf9d 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1356,56 +1356,67 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename, _Py_IDENTIFIER(offset); _Py_IDENTIFIER(text); - /* new style errors. `err' is an instance */ + *message = NULL; - if (! (v = _PyObject_GetAttrId(err, &PyId_msg))) + /* new style errors. `err' is an instance */ + *message = _PyObject_GetAttrId(err, &PyId_msg); + if (!*message) goto finally; - *message = v; - if (!(v = _PyObject_GetAttrId(err, &PyId_filename))) + v = _PyObject_GetAttrId(err, &PyId_filename); + if (!v) goto finally; - if (v == Py_None) + if (v == Py_None) { + Py_DECREF(v); *filename = NULL; - else if (! (*filename = _PyUnicode_AsString(v))) - goto finally; + } + else { + *filename = _PyUnicode_AsString(v); + Py_DECREF(v); + if (!*filename) + goto finally; + } - Py_DECREF(v); - if (!(v = _PyObject_GetAttrId(err, &PyId_lineno))) + 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; } |