Example #1
0
    pass


class foo:
    def __init__(self):

        self.a = False
        self.b = True
        self.c = None
        self.f = a_test_function
        self.k = a_test_class


# If this Python doesn't have True/False, then the unpickler
# will return 1/0 instead
if not pyconfig.Have_TrueFalse():
    True = 1
    False = 0

# the tests are portable versions of those in test_bools.py

# bools inside an object
x = xmp.loads(x1)

# check it
if x.a != False or x.b != True or x.c != None or \
   x.f != a_test_function or x.k != a_test_class:
    #print x.__dict__
    raise "ERROR(1)"

# bools inside a toplevel bltin
Example #2
0
import gnosis.pyconfig as pyconfig

# Get appropriate array type.
try:
    from Numeric import *
    array_type = 'NumPy_array'
except ImportError:
    from array import *
    array_type = 'array'

# Define exceptions and flags
XMLPicklingError = "gnosis.xml.pickle.XMLPicklingError"
XMLUnpicklingError = "gnosis.xml.pickle.XMLUnpicklingError"

# Define our own TRUE/FALSE syms, based on Python version.
if pyconfig.Have_TrueFalse():
    # Python 2.2 and up have a True/False (even though it's
    # a completely different value between 2.2 & 2.3)
    TRUE_VALUE = True
    FALSE_VALUE = False
else:
    # Below 2.2 has no True/False, so define them as they
    # are in 2.2 (this allows Python < 2.2 to read pickles
    # with bools created by Python 2.2+. Of course, if those
    # pickles are then rewritten, they'll lose their true/false
    # meaning, but hey, there's only so much we can do! :-)
    TRUE_VALUE = 1
    FALSE_VALUE = 0


# entry point expected by XML_Pickle