Skip to content

Commit

Permalink
Dynamically rewrite old cPickle'd feeds.
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Miller <jack@codezen.org>
  • Loading branch information
themoken committed May 25, 2010
1 parent 0f43683 commit 46076ff
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions canto/feed.py
Expand Up @@ -70,6 +70,20 @@ def get_ufp(self):
try: try:
fcntl.flock(f.fileno(), lockflags) fcntl.flock(f.fileno(), lockflags)
ufp = cPickle.load(f) 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: except:
return 0 return 0
finally: finally:
Expand Down

0 comments on commit 46076ff

Please sign in to comment.