[Zope3-checkins] CVS: Zope3/src/zope/xmlpickle - ppml.py:1.5.4.2
Fred L. Drake, Jr.
fred at zope.com
Thu Sep 11 18:21:22 EDT 2003
Update of /cvs-repository/Zope3/src/zope/xmlpickle
In directory cvs.zope.org:/tmp/cvs-serv26831
Modified Files:
Tag: parentgeddon-branch
ppml.py
Log Message:
make this work for Python 2.2.x as well as Python 2.3
=== Zope3/src/zope/xmlpickle/ppml.py 1.5.4.1 => 1.5.4.2 ===
--- Zope3/src/zope/xmlpickle/ppml.py:1.5.4.1 Thu Sep 11 16:55:30 2003
+++ Zope3/src/zope/xmlpickle/ppml.py Thu Sep 11 17:21:22 2003
@@ -24,7 +24,18 @@
BINUNICODE, TUPLE, EMPTY_TUPLE, EMPTY_LIST, EMPTY_DICT, LIST, \
DICT, INST, OBJ, GLOBAL, REDUCE, GET, BINGET, LONG_BINGET, PUT, \
BINPUT, LONG_BINPUT, STOP, MARK, BUILD, SETITEMS, SETITEM, \
- BINPERSID, APPEND, APPENDS, NEWTRUE, NEWFALSE
+ BINPERSID, APPEND, APPENDS
+
+try:
+ from pickle import NEWTRUE, NEWFALSE
+except ImportError:
+ TRUE = INT + "01\n"
+ FALSE = INT + "00\n"
+ _bool_support = False
+else:
+ TRUE = NEWTRUE
+ FALSE = NEWFALSE
+ _bool_support = True
from cStringIO import StringIO
@@ -480,13 +491,14 @@
self.append(none)
dispatch[NONE] = load_none
- def load_false(self):
- self.append(false)
- dispatch[NEWFALSE] = load_false
-
- def load_true(self):
- self.append(true)
- dispatch[NEWTRUE] = load_true
+ if _bool_support:
+ def load_false(self):
+ self.append(false)
+ dispatch[NEWFALSE] = load_false
+
+ def load_true(self):
+ self.append(true)
+ dispatch[NEWTRUE] = load_true
def load_int(self):
s = self.readline()[:-1]
@@ -766,11 +778,11 @@
def none(self, tag, data, NONE_tuple = (NONE, )):
return NONE_tuple
- def true(self, tag, data, TRUE_tuple = (NEWTRUE, )):
- return TRUE_tuple
+ def true(self, tag, data):
+ return TRUE,
- def false(self, tag, data, FALSE_tuple = (NEWFALSE, )):
- return FALSE_tuple
+ def false(self, tag, data):
+ return FALSE,
def long(self, tag, data):
return ((LONG + ''.join(data[2:]).strip().encode('ascii') + 'L\n'), )
More information about the Zope3-Checkins
mailing list