Mercurial > cpython-lru_cache-weakref
comparison Python/sysmodule.c @ 72848:81380082d216
Use identifier API for PyObject_GetAttrString.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Mon, 10 Oct 2011 18:11:30 +0200 |
| parents | 5e33219492bc |
| children | 7109f31300fb |
comparison
equal
deleted
inserted
replaced
| 72847:f924e0f62bcb | 72848:81380082d216 |
|---|---|
| 77 { | 77 { |
| 78 PyObject *stdout_encoding = NULL; | 78 PyObject *stdout_encoding = NULL; |
| 79 PyObject *encoded, *escaped_str, *repr_str, *buffer, *result; | 79 PyObject *encoded, *escaped_str, *repr_str, *buffer, *result; |
| 80 char *stdout_encoding_str; | 80 char *stdout_encoding_str; |
| 81 int ret; | 81 int ret; |
| 82 | 82 _Py_identifier(encoding); |
| 83 stdout_encoding = PyObject_GetAttrString(outf, "encoding"); | 83 _Py_identifier(buffer); |
| 84 | |
| 85 stdout_encoding = _PyObject_GetAttrId(outf, &PyId_encoding); | |
| 84 if (stdout_encoding == NULL) | 86 if (stdout_encoding == NULL) |
| 85 goto error; | 87 goto error; |
| 86 stdout_encoding_str = _PyUnicode_AsString(stdout_encoding); | 88 stdout_encoding_str = _PyUnicode_AsString(stdout_encoding); |
| 87 if (stdout_encoding_str == NULL) | 89 if (stdout_encoding_str == NULL) |
| 88 goto error; | 90 goto error; |
| 95 "backslashreplace"); | 97 "backslashreplace"); |
| 96 Py_DECREF(repr_str); | 98 Py_DECREF(repr_str); |
| 97 if (encoded == NULL) | 99 if (encoded == NULL) |
| 98 goto error; | 100 goto error; |
| 99 | 101 |
| 100 buffer = PyObject_GetAttrString(outf, "buffer"); | 102 buffer = _PyObject_GetAttrId(outf, &PyId_buffer); |
| 101 if (buffer) { | 103 if (buffer) { |
| 102 _Py_identifier(write); | 104 _Py_identifier(write); |
| 103 result = _PyObject_CallMethodId(buffer, &PyId_write, "(O)", encoded); | 105 result = _PyObject_CallMethodId(buffer, &PyId_write, "(O)", encoded); |
| 104 Py_DECREF(buffer); | 106 Py_DECREF(buffer); |
| 105 Py_DECREF(encoded); | 107 Py_DECREF(encoded); |
| 1839 static int | 1841 static int |
| 1840 sys_pyfile_write_unicode(PyObject *unicode, PyObject *file) | 1842 sys_pyfile_write_unicode(PyObject *unicode, PyObject *file) |
| 1841 { | 1843 { |
| 1842 PyObject *writer = NULL, *args = NULL, *result = NULL; | 1844 PyObject *writer = NULL, *args = NULL, *result = NULL; |
| 1843 int err; | 1845 int err; |
| 1846 _Py_identifier(write); | |
| 1844 | 1847 |
| 1845 if (file == NULL) | 1848 if (file == NULL) |
| 1846 return -1; | 1849 return -1; |
| 1847 | 1850 |
| 1848 writer = PyObject_GetAttrString(file, "write"); | 1851 writer = _PyObject_GetAttrId(file, &PyId_write); |
| 1849 if (writer == NULL) | 1852 if (writer == NULL) |
| 1850 goto error; | 1853 goto error; |
| 1851 | 1854 |
| 1852 args = PyTuple_Pack(1, unicode); | 1855 args = PyTuple_Pack(1, unicode); |
| 1853 if (args == NULL) | 1856 if (args == NULL) |
