diff Modules/_csv.c @ 43918:146ba97ffe1a

Correct test_cvs on Windows, as suggested by Raghuram Devarakonda in issue1395. All other places in this file already use newline=''... Also check that csv.reader is given an iterable returning strings.
author Amaury Forgeot d'Arc <amauryfa@gmail.com>
date Mon, 19 Nov 2007 21:20:21 +0000
parents 8ed0280c2ab6
children 7b30111247f6
line wrap: on
line diff
--- a/Modules/_csv.c	Mon Nov 19 21:14:47 2007 +0000
+++ b/Modules/_csv.c	Mon Nov 19 21:20:21 2007 +0000
@@ -270,7 +270,7 @@
 			*target = NULL;
 		else if (!IS_BASESTRING(src)) {
 			PyErr_Format(PyExc_TypeError, 
-				     "\"%s\" must be an string", name);
+				     "\"%s\" must be a string", name);
 			return -1;
 		}
 		else {
@@ -793,6 +793,16 @@
 					     "newline inside string");
                         return NULL;
                 }
+		if (!PyUnicode_Check(lineobj))
+		{
+			PyErr_Format(error_obj,
+				     "Iterator should return strings, "
+				     "not %.200s "
+				     "(did you open the file in text mode?)",
+				     lineobj->ob_type->tp_name
+				);
+			return NULL;
+		}
                 ++self->line_num;
                 line = PyUnicode_AsUnicode(lineobj);
                 linelen = PyUnicode_GetSize(lineobj);