diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2011-10-14 13:16:45 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2011-10-14 13:16:45 (GMT) |
commit | 1c67dd9b154d57baf58ed081767e199af1e84923 (patch) | |
tree | 0d6c95e99785f9b8381c808a5cb433adf319eda5 /Python/errors.c | |
parent | bd928fef428e48084ff29ece0e21d07ad86d0793 (diff) | |
download | cpython-1c67dd9b154d57baf58ed081767e199af1e84923.zip cpython-1c67dd9b154d57baf58ed081767e199af1e84923.tar.gz cpython-1c67dd9b154d57baf58ed081767e199af1e84923.tar.bz2 |
Port SetAttrString/HasAttrString to SetAttrId/GetAttrId.
Diffstat (limited to 'Python/errors.c')
-rw-r--r-- | Python/errors.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/Python/errors.c b/Python/errors.c index 998bef6..d62648b 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -780,6 +780,12 @@ void PyErr_SyntaxLocationEx(const char *filename, int lineno, int col_offset) { PyObject *exc, *v, *tb, *tmp; + _Py_IDENTIFIER(filename); + _Py_IDENTIFIER(lineno); + _Py_IDENTIFIER(msg); + _Py_IDENTIFIER(offset); + _Py_IDENTIFIER(print_file_and_line); + _Py_IDENTIFIER(text); /* add attributes for the line number and filename for the error */ PyErr_Fetch(&exc, &v, &tb); @@ -790,7 +796,7 @@ PyErr_SyntaxLocationEx(const char *filename, int lineno, int col_offset) if (tmp == NULL) PyErr_Clear(); else { - if (PyObject_SetAttrString(v, "lineno", tmp)) + if (_PyObject_SetAttrId(v, &PyId_lineno, tmp)) PyErr_Clear(); Py_DECREF(tmp); } @@ -799,7 +805,7 @@ PyErr_SyntaxLocationEx(const char *filename, int lineno, int col_offset) if (tmp == NULL) PyErr_Clear(); else { - if (PyObject_SetAttrString(v, "offset", tmp)) + if (_PyObject_SetAttrId(v, &PyId_offset, tmp)) PyErr_Clear(); Py_DECREF(tmp); } @@ -809,35 +815,35 @@ PyErr_SyntaxLocationEx(const char *filename, int lineno, int col_offset) if (tmp == NULL) PyErr_Clear(); else { - if (PyObject_SetAttrString(v, "filename", tmp)) + if (_PyObject_SetAttrId(v, &PyId_filename, tmp)) PyErr_Clear(); Py_DECREF(tmp); } tmp = PyErr_ProgramText(filename, lineno); if (tmp) { - if (PyObject_SetAttrString(v, "text", tmp)) + if (_PyObject_SetAttrId(v, &PyId_text, tmp)) PyErr_Clear(); Py_DECREF(tmp); } } - if (PyObject_SetAttrString(v, "offset", Py_None)) { + if (_PyObject_SetAttrId(v, &PyId_offset, Py_None)) { PyErr_Clear(); } if (exc != PyExc_SyntaxError) { - if (!PyObject_HasAttrString(v, "msg")) { + if (!_PyObject_HasAttrId(v, &PyId_msg)) { tmp = PyObject_Str(v); if (tmp) { - if (PyObject_SetAttrString(v, "msg", tmp)) + if (_PyObject_SetAttrId(v, &PyId_msg, tmp)) PyErr_Clear(); Py_DECREF(tmp); } else { PyErr_Clear(); } } - if (!PyObject_HasAttrString(v, "print_file_and_line")) { - if (PyObject_SetAttrString(v, "print_file_and_line", - Py_None)) + if (!_PyObject_HasAttrId(v, &PyId_print_file_and_line)) { + if (_PyObject_SetAttrId(v, &PyId_print_file_and_line, + Py_None)) PyErr_Clear(); } } |