summaryrefslogtreecommitdiffstats
path: root/Python/errors.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/Python/errors.c b/Python/errors.c
index 7b25a22..6095843 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -1059,16 +1059,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();
@@ -1080,9 +1079,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);
@@ -1148,11 +1144,8 @@ err_programtext(FILE *fp, int lineno)
}
fclose(fp);
if (i == lineno) {
- char *p = linebuf;
PyObject *res;
- while (*p == ' ' || *p == '\t' || *p == '\014')
- p++;
- res = PyUnicode_FromString(p);
+ res = PyUnicode_FromString(linebuf);
if (res == NULL)
PyErr_Clear();
return res;