summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-12-11 12:44:21 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-12-11 12:44:21 (GMT)
commit26817a84908b831d71dd59de432f75829a5bae33 (patch)
tree155827823d4c5c344adbae096cbbe2f634263b45 /Python
parent2b27c2ddbaee778b4de128bd43359b66dcda01f8 (diff)
parent8114f21668fe9775d2542d079c6396a745f4f094 (diff)
downloadcpython-26817a84908b831d71dd59de432f75829a5bae33.zip
cpython-26817a84908b831d71dd59de432f75829a5bae33.tar.gz
cpython-26817a84908b831d71dd59de432f75829a5bae33.tar.bz2
Issue #28512: Fixed setting the offset attribute of SyntaxError by
PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().
Diffstat (limited to 'Python')
-rw-r--r--Python/errors.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/Python/errors.c b/Python/errors.c
index 74283c9..35c9e3a 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -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);