From 5d858465b6ebdafa05f86309457848cc26913b6a Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 20 Nov 2016 10:16:47 +0200 Subject: Added the const qualifier to char* variables that refer to readonly internal UTF-8 represenatation of Unicode objects. --- Objects/fileobject.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'Objects/fileobject.c') 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); -- cgit v1.2.1 From 40273ec4f37c65c13a09d0ac23b08c99ebe2f1a3 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 5 Dec 2016 17:04:32 +0100 Subject: Issue #28858: Remove _PyObject_CallArg1() macro Replace _PyObject_CallArg1(func, arg) with PyObject_CallFunctionObjArgs(func, arg, NULL) Using the _PyObject_CallArg1() macro increases the usage of the C stack, which was unexpected and unwanted. PyObject_CallFunctionObjArgs() doesn't have this issue. --- Objects/fileobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Objects/fileobject.c') diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 32f8a8983e..fcdb5fd0a4 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -146,7 +146,7 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags) Py_DECREF(writer); return -1; } - result = _PyObject_CallArg1(writer, value); + result = PyObject_CallFunctionObjArgs(writer, value, NULL); Py_DECREF(value); Py_DECREF(writer); if (result == NULL) -- cgit v1.2.1 From bfeec6d871e3db2e0ddfdef01387913bc19cadd4 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 23 Jan 2017 09:47:21 +0200 Subject: Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever possible. Patch is writen with Coccinelle. --- Objects/fileobject.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Objects/fileobject.c') diff --git a/Objects/fileobject.c b/Objects/fileobject.c index fcdb5fd0a4..3c3d46da51 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -456,8 +456,7 @@ static PyMethodDef stdprinter_methods[] = { static PyObject * get_closed(PyStdPrinter_Object *self, void *closure) { - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } static PyObject * -- cgit v1.2.1