diff options
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 5053f7a174..3b0d64ff14 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1820,8 +1820,9 @@ static PyObject * builtin_print(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { static const char * const _keywords[] = {"sep", "end", "file", "flush", 0}; - static struct _PyArg_Parser _parser = {"|OOOO:print", _keywords, 0}; - PyObject *sep = NULL, *end = NULL, *file = NULL, *flush = NULL; + static struct _PyArg_Parser _parser = {"|OOOp:print", _keywords, 0}; + PyObject *sep = NULL, *end = NULL, *file = NULL; + int flush = 0; int i, err; if (kwnames != NULL && @@ -1883,18 +1884,11 @@ builtin_print(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject if (err) return NULL; - if (flush != NULL) { - PyObject *tmp; - int do_flush = PyObject_IsTrue(flush); - if (do_flush == -1) + if (flush) { + PyObject *tmp = _PyObject_CallMethodIdNoArgs(file, &PyId_flush); + if (tmp == NULL) return NULL; - else if (do_flush) { - tmp = _PyObject_CallMethodIdNoArgs(file, &PyId_flush); - if (tmp == NULL) - return NULL; - else - Py_DECREF(tmp); - } + Py_DECREF(tmp); } Py_RETURN_NONE; |