diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-11 12:39:01 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-11 12:39:01 (GMT) |
commit | 8b58339eb2939da4df822f7ea457b44e120fad45 (patch) | |
tree | d34029d80314da5bea6e6fccbc9f07e74fa50457 /Python | |
parent | 49c14d8e8fe8f1897eef72ef45665b7afeec32d6 (diff) | |
download | cpython-8b58339eb2939da4df822f7ea457b44e120fad45.zip cpython-8b58339eb2939da4df822f7ea457b44e120fad45.tar.gz cpython-8b58339eb2939da4df822f7ea457b44e120fad45.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.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/Python/errors.c b/Python/errors.c index dd01448..ebfb3fd 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -1009,16 +1009,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(); @@ -1030,9 +1029,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); |