[Collab-qa-commits] r1755 - udd/udd

Andreas Tille tille at alioth.debian.org
Thu Jul 1 07:38:57 UTC 2010


Author: tille
Date: 2010-07-01 07:38:50 +0000 (Thu, 01 Jul 2010)
New Revision: 1755

Modified:
   udd/udd/ddtp_gatherer.py
Log:
Fix encoding problem when printing warning messages


Modified: udd/udd/ddtp_gatherer.py
===================================================================
--- udd/udd/ddtp_gatherer.py	2010-06-29 14:02:41 UTC (rev 1754)
+++ udd/udd/ddtp_gatherer.py	2010-07-01 07:38:50 UTC (rev 1755)
@@ -28,6 +28,11 @@
 fileConfig("logging.ini")
 
 debug=0
+def to_unicode(value, encoding='utf-8'):
+    if isinstance(value, str):
+	return value.decode(encoding)
+    else:
+        return unicode(value)
 
 def get_gatherer(connection, config, source):
   return ddtp_gatherer(connection, config, source)
@@ -212,7 +217,7 @@
               cur.execute(query)
             except IntegrityError, err:
               self.log.exception("Duplicated key in language %s: (%s)", self.pkg.language,
-                                 ", ".join([item.encode('utf-8') for item in (self.pkg.package, self.pkg.version, self.pkg.description, self.pkg.md5sum)]))
+                                 ", ".join([to_unicode(item) for item in (self.pkg.package, self.pkg.version, self.pkg.description, self.pkg.md5sum)]))
               self.connection.rollback()
               continue
         except IOError, err:




More information about the Collab-qa-commits mailing list