[Zodb-checkins] CVS: ZODB3/ZODB - referencesf.py:1.6.94.1
Jeremy Hylton
jeremy at zope.com
Thu Oct 2 16:47:24 EDT 2003
Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv11450
Modified Files:
Tag: Zope-2_7-branch
referencesf.py
Log Message:
Remove use of default arguments for shadowing globals.
Use modern spellings of type operations.
Add whitespace.
=== ZODB3/ZODB/referencesf.py 1.6 => 1.6.94.1 ===
--- ZODB3/ZODB/referencesf.py:1.6 Wed Aug 14 18:07:09 2002
+++ ZODB3/ZODB/referencesf.py Thu Oct 2 16:47:23 2003
@@ -13,35 +13,37 @@
##############################################################################
"""Provide a function that can find object references in pickles
"""
-import cPickle, cStringIO
+import cPickle import Unpickler
+from cStringIO import StringIO
-def referencesf(p, rootl=None,
- Unpickler=cPickle.Unpickler,
- StringIO=cStringIO.StringIO,
- tt=type(()),
- type=type):
-
- if rootl is None: rootl=[]
- u=Unpickler(StringIO(p))
- l=len(rootl)
- u.persistent_load=rootl
+def referencesf(p, rootl=None):
+ if rootl is None:
+ rootl = []
+ u = Unpickler(StringIO(p))
+ l = len(rootl)
+ # If persistent_load is set to a list, the pickler will append
+ # persistent ids to it instead of calling it.
+ u.persistent_load = rootl
u.noload()
- try: u.noload()
+ try:
+ u.noload()
except:
# Hm. We failed to do second load. Maybe there wasn't a
# second pickle. Let's check:
- f=StringIO(p)
- u=Unpickler(f)
- u.persistent_load=[]
+ f = StringIO(p)
+ u = Unpickler(f)
+ u.persistent_load = []
u.noload()
- if len(p) > f.tell(): raise ValueError, 'Error unpickling, %s' % p
+ if len(p) > f.tell():
+ raise ValueError, 'Error unpickling, %s' % p
# References may have class info, so we need to
# check for wrapped references.
for i in range(l, len(rootl)):
- v=rootl[i]
+ v = rootl[i]
if v:
- if type(v) is tt: v=v[0]
- rootl[i]=v
+ if isinstance(v, tuple):
+ v = v[0]
+ rootl[i] = v
return rootl
More information about the Zodb-checkins
mailing list