From: Thomas Jarosch Date: Thu, 5 Jul 2012 08:44:55 +0000 (+0200) Subject: Handle difference in pickle protocol between python 2.x and 3.x X-Git-Url: http://developer.intra2net.com/git/?p=imap-fix-internaldate;a=commitdiff_plain;h=04d3d4de7ede662b61f3ff8f670b5b4c347550b4 Handle difference in pickle protocol between python 2.x and 3.x --- diff --git a/src/caching_data.py b/src/caching_data.py index 0610f7d..c3a614c 100644 --- a/src/caching_data.py +++ b/src/caching_data.py @@ -42,16 +42,15 @@ class CachingData: cache_info = cache_info.split(' ') self.version = cache_info[0] if(self.version != CACHE_VERSION): - logging.warning("Cache file has version %s and the script version is %s. Deleting cache.", - self.version, CACHE_VERSION) - raise IOError + raise IOError("Cache file has version %s and the script version is %s" % (self.version, CACHE_VERSION)) self.fallback_to_date_header = cache_info[1] if(self.fallback_to_date_header != str(fallback_mode)): - logging.warning("Cache file date fallback mode setting is different than current settings. Deleting cache.") - raise IOError + raise IOError("Cache file date fallback mode setting is different than current settings") logging.info("Cache file %s loaded", CACHE_FILENAME) - logging.debug("%s users found.", len(self.data)) - except IOError: + logging.info("%s users found.", len(self.data)) + except (IOError, ValueError) as ex: + logging.warning("Couldn't load cache file %s: %s", CACHE_FILENAME, ex) + logging.warning("DELETING CACHE") self.version = CACHE_VERSION stored_cache_info = self.version + ' ' + str(fallback_mode) self.data = {}