[Yum-devel] [PATCH] configure sqlite to return utf-8-encoded strs instead of unicode objects

Mike Bonnet mikeb at redhat.com
Thu Aug 6 17:50:53 UTC 2009

sqlite by default returns all text as unicode objects, and this causes a 
number of problems when merging repos which contain utf-8 characters in 
Provides or Requires (as the current F11/F12 repos do).  For a testcase, 
try merging 2 F12 repos, and you should see it fail with a 
UnicodeDecodeError in packages.py:_dump_pco().  This patch instructs 
sqlite to return all text as utf-8-encoded strs, which avoids these 
encoding issues.

  sqlitecachec.py |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/sqlitecachec.py b/sqlitecachec.py
index 7ed5056..8b0ca08 100644
--- a/sqlitecachec.py
+++ b/sqlitecachec.py
@@ -29,6 +29,7 @@ class RepodataParserSqlite:
          if not filename:
              return None
          con = sqlite.connect(filename)
+        con.text_factory = str
          if sqlite.version_info[0] > 1:
              con.row_factory = sqlite.Row
          cur = con.cursor()

More information about the Yum-devel mailing list