From 46076ff0146ac5af14e7a1ac8a125ef59b17b3cc Mon Sep 17 00:00:00 2001 From: Jack Miller Date: Mon, 24 May 2010 19:22:36 -0500 Subject: [PATCH] Dynamically rewrite old cPickle'd feeds. Signed-off-by: Jack Miller --- canto/feed.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/canto/feed.py b/canto/feed.py index 4a786fe..186ddad 100644 --- a/canto/feed.py +++ b/canto/feed.py @@ -70,6 +70,20 @@ def get_ufp(self): try: fcntl.flock(f.fileno(), lockflags) ufp = cPickle.load(f) + except ImportError: + try: + + # Fortunately, I don't think forcing the cpickle + # to use feedparser_builtin is harmful, since they're + # basically the same class, feedparser_builtin is just the + # only way to properly look up the toplevel module now. + + f.seek(0) + data = f.read() + data = data.replace("feedparser\n","feedparser_builtin\n",1) + ufp = cPickle.loads(data) + except: + return 0 except: return 0 finally: