[Python-checkins] r73780 - python/branches/py3k/Python/bltinmodule.c

benjamin.peterson python-checkins at python.org
Thu Jul 2 20:25:27 CEST 2009


Author: benjamin.peterson
Date: Thu Jul  2 20:25:26 2009
New Revision: 73780

Log:
refactor logic a little when no sep or end is passed

Modified:
   python/branches/py3k/Python/bltinmodule.c

Modified: python/branches/py3k/Python/bltinmodule.c
==============================================================================
--- python/branches/py3k/Python/bltinmodule.c	(original)
+++ python/branches/py3k/Python/bltinmodule.c	Thu Jul  2 20:25:26 2009
@@ -1459,13 +1459,19 @@
 			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 @@
 
 	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 @@
 			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);


More information about the Python-checkins mailing list