Issue #28512: Fixed setting the offset attribute of SyntaxError by

PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().
This commit is contained in:
Serhiy Storchaka 2016-12-11 14:44:21 +02:00
commit 26817a8490
8 changed files with 56 additions and 60 deletions

View file

@ -1053,16 +1053,15 @@ PyErr_SyntaxLocationObject(PyObject *filename, int lineno, int col_offset)
PyErr_Clear();
Py_DECREF(tmp);
}
tmp = NULL;
if (col_offset >= 0) {
tmp = PyLong_FromLong(col_offset);
if (tmp == NULL)
PyErr_Clear();
else {
if (_PyObject_SetAttrId(v, &PyId_offset, tmp))
PyErr_Clear();
Py_DECREF(tmp);
}
}
if (_PyObject_SetAttrId(v, &PyId_offset, tmp ? tmp : Py_None))
PyErr_Clear();
Py_XDECREF(tmp);
if (filename != NULL) {
if (_PyObject_SetAttrId(v, &PyId_filename, filename))
PyErr_Clear();
@ -1074,9 +1073,6 @@ PyErr_SyntaxLocationObject(PyObject *filename, int lineno, int col_offset)
Py_DECREF(tmp);
}
}
if (_PyObject_SetAttrId(v, &PyId_offset, Py_None)) {
PyErr_Clear();
}
if (exc != PyExc_SyntaxError) {
if (!_PyObject_HasAttrId(v, &PyId_msg)) {
tmp = PyObject_Str(v);