Mercurial > cpython-lru_cache-weakref
diff Python/pythonrun.c @ 72926:db4aa878cea2
Port SetAttrString/HasAttrString to SetAttrId/GetAttrId.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Fri, 14 Oct 2011 15:16:45 +0200 |
| parents | 7109f31300fb |
| children | af0800b986b7 |
line wrap: on
line diff
--- a/Python/pythonrun.c Fri Oct 14 10:20:37 2011 +0200 +++ b/Python/pythonrun.c Fri Oct 14 15:16:45 2011 +0200 @@ -810,6 +810,8 @@ _Py_IDENTIFIER(open); _Py_IDENTIFIER(isatty); _Py_IDENTIFIER(TextIOWrapper); + _Py_IDENTIFIER(name); + _Py_IDENTIFIER(mode); /* stdin is always opened in buffered mode, first because it shouldn't make a difference in common use cases, second because TextIOWrapper @@ -842,7 +844,7 @@ } text = PyUnicode_FromString(name); - if (text == NULL || PyObject_SetAttrString(raw, "name", text) < 0) + if (text == NULL || _PyObject_SetAttrId(raw, &PyId_name, text) < 0) goto error; res = _PyObject_CallMethodId(raw, &PyId_isatty, ""); if (res == NULL) @@ -879,7 +881,7 @@ else mode = "r"; text = PyUnicode_FromString(mode); - if (!text || PyObject_SetAttrString(stream, "mode", text) < 0) + if (!text || _PyObject_SetAttrId(stream, &PyId_mode, text) < 0) goto error; Py_CLEAR(text); return stream; @@ -1547,6 +1549,7 @@ { int err = 0; PyObject *type, *tb; + _Py_IDENTIFIER(print_file_and_line); if (!PyExceptionInstance_Check(value)) { PyFile_WriteString("TypeError: print_exception(): Exception expected for value, ", f); @@ -1562,7 +1565,7 @@ if (tb && tb != Py_None) err = PyTraceBack_Print(tb, f); if (err == 0 && - PyObject_HasAttrString(value, "print_file_and_line")) + _PyObject_HasAttrId(value, &PyId_print_file_and_line)) { PyObject *message; const char *filename, *text;
