Fix regression in _getitem() from r14398, since myf.read().split("\n")
authorZac Medico <zmedico@gentoo.org>
Thu, 24 Sep 2009 22:15:48 +0000 (22:15 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 24 Sep 2009 22:15:48 +0000 (22:15 -0000)
yields an empty string at the end which is causes _parse_data() to
catch a ValueError and raise CacheCorruption.

svn path=/main/trunk/; revision=14416

pym/portage/cache/flat_hash.py

index 983055a4b8672775051d3061b49f56b3d9814ac9..49d7ce6a0c756cd4088905fa1b37d21220ddd263 100644 (file)
@@ -41,7 +41,10 @@ class database(fs_template.FsBased):
                                mode='r', encoding=_encodings['repo.content'],
                                errors='replace')
                        try:
-                               d = self._parse_data(myf.read().split("\n"), cpv)
+                               lines = myf.read().split("\n")
+                               if not lines[-1]:
+                                       lines.pop()
+                               d = self._parse_data(lines, cpv)
                                if '_mtime_' not in d:
                                        # Backward compatibility with old cache
                                        # that uses mtime mangling.