diff Modules/_csv.c @ 44019:7b30111247f6

#1479: Fix refleak in csv module (from rev 59062).
author Georg Brandl <georg@python.org>
date Sun, 25 Nov 2007 00:52:21 +0000
parents 146ba97ffe1a
children 8f92b4ee6fc4
line wrap: on
line diff
--- a/Modules/_csv.c	Sun Nov 25 00:45:05 2007 +0000
+++ b/Modules/_csv.c	Sun Nov 25 00:52:21 2007 +0000
@@ -793,14 +793,13 @@
 					     "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?)",
+		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
 				);
+			Py_DECREF(lineobj);
 			return NULL;
 		}
                 ++self->line_num;