Permalink
Browse files

Dynamically rewrite old cPickle'd feeds.

Signed-off-by: Jack Miller <jack@codezen.org>
  • Loading branch information...
1 parent 0f43683 commit 46076ff0146ac5af14e7a1ac8a125ef59b17b3cc @themoken committed May 25, 2010
Showing with 14 additions and 0 deletions.
  1. +14 −0 canto/feed.py
View
@@ -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:

0 comments on commit 46076ff

Please sign in to comment.