str() method will fail if there are non-ascii characters in the string.
A "UnicodeEncodeError: 'ascii' codec can't encode characters..." error
will be generated in this case.

Since this method is used by the scheduler to setup emails, the
scheduler can get into a nasty failure loop here.

The fix is simply to encode the string as utf-8. This fixes the original
issue introduced with http://autotest.kernel.org/changeset/5076

Signed-off-by: Dale Curtis <[email protected]>
---
 client/common_lib/base_utils.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/client/common_lib/base_utils.py b/client/common_lib/base_utils.py
index db7b869..19a7c53 100644
--- a/client/common_lib/base_utils.py
+++ b/client/common_lib/base_utils.py
@@ -246,7 +246,7 @@ def matrix_to_string(matrix, header=None):
             lengths.append(len(column))
     for row in matrix:
         for i, column in enumerate(row):
-            column = str(column)
+            column = str(unicode(column).encode("utf-8"))
             cl = len(column)
             try:
                 ml = lengths[i]
-- 
1.7.3.1
From 1b138cdfb491de5f72657911eacdf1fab6b53343 Mon Sep 17 00:00:00 2001
From: Dale Curtis <[email protected]>
Date: Mon, 20 Jun 2011 15:59:37 -0700
Subject: [PATCH 1/4] Fix unicode conversion errors in matrix_to_string().

str() method will fail if there are non-ascii characters in the string.
A "UnicodeEncodeError: 'ascii' codec can't encode characters..." error
will be generated in this case.

Since this method is used by the scheduler to setup emails, the
scheduler can get into a nasty failure loop here.

The fix is simply to encode the string as utf-8. This fixes the original
issue introduced with http://autotest.kernel.org/changeset/5076

Signed-off-by: Dale Curtis <[email protected]>
---
 client/common_lib/base_utils.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/client/common_lib/base_utils.py b/client/common_lib/base_utils.py
index db7b869..19a7c53 100644
--- a/client/common_lib/base_utils.py
+++ b/client/common_lib/base_utils.py
@@ -246,7 +246,7 @@ def matrix_to_string(matrix, header=None):
             lengths.append(len(column))
     for row in matrix:
         for i, column in enumerate(row):
-            column = str(column)
+            column = str(unicode(column).encode("utf-8"))
             cl = len(column)
             try:
                 ml = lengths[i]
-- 
1.7.3.1

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to