cache/sqlite.py: translate None to empty string
authorZac Medico <zmedico@gentoo.org>
Tue, 25 Sep 2012 01:54:32 +0000 (18:54 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 25 Sep 2012 01:54:32 +0000 (18:54 -0700)
pym/portage/cache/sqlite.py

index 1038bb2ab4fc75cec63a4de6fd1ddb74b5507041..9c1b3eb7eedd4d1ec17aad9ba24b0da51b7a1621 100644 (file)
@@ -21,7 +21,7 @@ class database(fs_template.FsBased):
        # to calculate the number of pages requested, according to the following
        # equation: cache_bytes = page_bytes * page_count
        cache_bytes = 1024 * 1024 * 10
-       _db_table = None
+       _EMPTY_STRING = _unicode_decode("")
 
        def __init__(self, *args, **config):
                super(database, self).__init__(*args, **config)
@@ -206,12 +206,17 @@ class database(fs_template.FsBased):
                        raise KeyError(cpv)
                else:
                        raise cache_errors.CacheCorruption(cpv, "key is not unique")
+               result = result[0]
                d = {}
                allowed_keys_set = self._allowed_keys_set
                for column_index, column_info in enumerate(cursor.description):
                        k = column_info[0]
                        if k in allowed_keys_set:
-                               d[k] = result[0][column_index]
+                               v = result[column_index]
+                               if v is None:
+                                       # This happens after a new empty column has been added.
+                                       v = self._EMPTY_STRING
+                               d[k] = v
 
                return d