Catch a ValueError caused by corrupt cache for bug #149134.
authorZac Medico <zmedico@gentoo.org>
Thu, 28 Sep 2006 00:15:57 +0000 (00:15 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 28 Sep 2006 00:15:57 +0000 (00:15 -0000)
svn path=/main/trunk/; revision=4545

pym/cache/flat_hash.py

index 1c687ecf395a8a9f83251d988a74c7673745dc5f..722e9f1847b87c1dc8cba98d2bb3d71d76911f25 100644 (file)
@@ -36,7 +36,11 @@ class database(fs_template.FsBased):
                        raise KeyError(cpv)
 
        def _parse_data(self, data, cpv):
-               d = dict(map(lambda x:x.rstrip().split("=", 1), data))
+               try:
+                       d = dict(map(lambda x:x.rstrip("\n").split("=", 1), data))
+               except ValueError, e:
+                       # If a line is missing an "=", the split length is 1 instead of 2.
+                       raise cache_errors.CacheCorruption(cpv, e)
                if "_eclasses_" in d:
                        d["_eclasses_"] = reconstruct_eclasses(cpv, d["_eclasses_"])
                return d