[Zope-Checkins] CVS: Zope/lib/python/TreeDisplay -
TreeTag.py:1.53.68.5
Casey Duncan
casey at zope.com
Thu Apr 29 14:58:57 EDT 2004
Update of /cvs-repository/Zope/lib/python/TreeDisplay
In directory cvs.zope.org:/tmp/cvs-serv27548/lib/python/TreeDisplay
Modified Files:
Tag: Zope-2_7-branch
TreeTag.py
Log Message:
Fix TreeTag persistence. Unpickler used to decode the state refused to decode strings, thereby rendering all tree-states undecodeable. Strings are now allowed to be unpickled.
=== Zope/lib/python/TreeDisplay/TreeTag.py 1.53.68.4 => 1.53.68.5 ===
--- Zope/lib/python/TreeDisplay/TreeTag.py:1.53.68.4 Thu Jan 8 18:33:59 2004
+++ Zope/lib/python/TreeDisplay/TreeTag.py Thu Apr 29 14:58:56 2004
@@ -673,7 +673,7 @@
dispatch = pickle.Unpickler.dispatch.copy()
for k,v in dispatch.items():
- if k=='' or k in '().012FGIJKLMNTUVX]adeghjlpqrstu}':
+ if k=='' or k in '().012FGIJKLMNSTUVX]adeghjlpqrstu}':
# This key is necessary and safe, so leave it in the map
pass
else:
@@ -685,21 +685,16 @@
elif k in [pickle.PERSID, pickle.BINPERSID]:
# These are just unnecessary
pass
- elif k in [pickle.STRING]:
- # This one is controversial: A string is harmlessm, but the
- # implementation of pickle leaks memory (strings may be interned)
- # The problem can be avoided by using binary pickles.
- pass
del k
del v
def _should_succeed(x,binary=1):
- if x != MiniUnpickler(StringIO(pickle.dumps(x,binary))).load():
+ if x != MiniUnpickler(StringIO(dumps(x,binary))).load():
raise ValueError(x)
def _should_fail(x,binary=1):
try:
- MiniUnpickler(StringIO(pickle.dumps(x,binary))).load()
+ MiniUnpickler(StringIO(dumps(x,binary))).load()
raise ValueError(x)
except pickle.UnpicklingError, e:
if e[0]!='Refused': raise ValueError(x)
@@ -707,7 +702,7 @@
class _junk_class: pass
def _test():
- _should_fail('hello',0)
+ _should_succeed('hello', binary=0)
_should_succeed('hello')
_should_succeed(1)
_should_succeed(1L)
@@ -720,4 +715,5 @@
_should_fail(_junk_class())
# Test MiniPickle on every import
+# XXX This *really* should be moved to a unittest!
_test()
More information about the Zope-Checkins
mailing list