summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-07-02 18:25:26 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-07-02 18:25:26 (GMT)
commitc963731bb68b844e839518af96d8b986cbbf9da9 (patch)
treee7310fdcae0052105f112437ae9ee984659e4716 /Python
parentb18d26d1d4ff1848d18bc8a7a8079aea38603c9d (diff)
downloadcpython-c963731bb68b844e839518af96d8b986cbbf9da9.zip
cpython-c963731bb68b844e839518af96d8b986cbbf9da9.tar.gz
cpython-c963731bb68b844e839518af96d8b986cbbf9da9.tar.bz2
refactor logic a little when no sep or end is passed
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index c33a37e..2224d37 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -1459,13 +1459,19 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
Py_RETURN_NONE;
}
- if (sep && sep != Py_None && !PyUnicode_Check(sep)) {
+ if (sep == Py_None) {
+ sep = NULL;
+ }
+ else if (sep && !PyUnicode_Check(sep)) {
PyErr_Format(PyExc_TypeError,
"sep must be None or a string, not %.200s",
sep->ob_type->tp_name);
return NULL;
}
- if (end && end != Py_None && !PyUnicode_Check(end)) {
+ if (end == Py_None) {
+ end = NULL;
+ }
+ else if (end && !PyUnicode_Check(end)) {
PyErr_Format(PyExc_TypeError,
"end must be None or a string, not %.200s",
end->ob_type->tp_name);
@@ -1474,7 +1480,7 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
for (i = 0; i < PyTuple_Size(args); i++) {
if (i > 0) {
- if (sep == NULL || sep == Py_None)
+ if (sep == NULL)
err = PyFile_WriteString(" ", file);
else
err = PyFile_WriteObject(sep, file,
@@ -1488,7 +1494,7 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
return NULL;
}
- if (end == NULL || end == Py_None)
+ if (end == NULL)
err = PyFile_WriteString("\n", file);
else
err = PyFile_WriteObject(end, file, Py_PRINT_RAW);