summaryrefslogtreecommitdiff
path: root/Objects/fileobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-11-20 10:16:47 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2016-11-20 10:16:47 +0200
commit5d858465b6ebdafa05f86309457848cc26913b6a (patch)
treeb7b6fc3238b3c9a4358d2b1523e6fa38d4e1469a /Objects/fileobject.c
parentabbf5f179143f0c4e96fe5e507ea5f69ea195c9e (diff)
downloadcpython-5d858465b6ebdafa05f86309457848cc26913b6a.tar.gz
Added the const qualifier to char* variables that refer to readonly internal
UTF-8 represenatation of Unicode objects.
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r--Objects/fileobject.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index f4424184d2..32f8a8983e 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -367,7 +367,7 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
{
PyObject *unicode;
PyObject *bytes = NULL;
- char *str;
+ const char *str;
Py_ssize_t n;
int err;
@@ -389,10 +389,8 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
bytes = _PyUnicode_AsUTF8String(unicode, "backslashreplace");
if (bytes == NULL)
return NULL;
- if (PyBytes_AsStringAndSize(bytes, &str, &n) < 0) {
- Py_DECREF(bytes);
- return NULL;
- }
+ str = PyBytes_AS_STRING(bytes);
+ n = PyBytes_GET_SIZE(bytes);
}
n = _Py_write(self->fd, str, n);