                d = inst.__dict__
                try:
                    for k, v in state.iteritems():
                        d[intern(k)] = v
                # keys in state don't have to be strings
                # don't blow up, but don't go out of our way
                except TypeError:
                    d.update(state)

            except RuntimeError:
                # XXX In restricted execution, the instance's __dict__
                # is not accessible.  Use the old way of unpickling
                # the instance variables.  This is a semantic
                # difference when unpickling in restricted
                # vs. unrestricted modes.
                # Note, however, that cPickle has never tried to do the
                #.update() business, and always uses
                #     PyObject_SetItem(inst.__dict__, key, value) in a
                # loop over state.items().
                for k, v in state.items():
                    setattr(inst, k, v)
        if slotstate:
            for k, v in slotstate.items():
                setattr(inst, k, v)
    dispatch[BUILD] = load_build

    def load_mark(self):
        self.append(self.mark)
    dispatch[MARK] = load_mark

    def load_stop(self):
        value = self.stack.pop()
        raise _Stop(value)
    dispatch[STOP] = load_stop

# Helper class for load_inst/load_obj

class _EmptyClass:
    pass

# Encode/decode longs in linear time.

import binascii as _binascii

def encode_long(x):
    r"""Encode a long to a two's complement little-endian binary string.
    Note that 0L is a special case, returning an empty string, to save a
    byte in the LONG1 pickling context.

    >>> encode_long(0L)
    ''
    >>> encode_long(255L)
    '\xff\x00'
    >>> encode_long(32767L)
    '\xff\x7f'
    >>> encode_long(-256L)
    '\x00\xff'
    >>> encode_long(-32768L)
    '\
d = inst.__dict _ _ 
                 try: 
                     for k, v in state.iteritems (): 
                         d[intern(k) ] = v 
                 # keys in state don't get to be chain 
                 # don't blow up, but don't go out of our way 
                 except TypeError: 
                     d.update(state) 

             except RuntimeError: 
                 # XXX In restricted murder, the instance's _ _ dict _ _ 
                 # is not accessible.   Use the erstwhile way of unpickling 
                 # the instance variable.   This is a semantic 
                 # difference when unpickling in restricted 
                 # vs. nonsensitive modes. 
                 # Note, however, that cPickle has never judge to do the 
                 # .update () business, and always uses 
                 #      PyObject_SetItem(inst.__dict _ _, key, value) in a 
                 # loop over state.items (). 
                 for k, volt in state.items (): 
                     setattr(inst, k, v) 
         if slotstate: 
             for k, v in slotstate.items (): 
                 setattr(inst, k, v) 
     dispatch[BUILD ] = load_build 

     def load_mark(self ): 
         self.append(self.mark) 
     dispatch[MARK ] = load_mark 

     def load_stop(self ): 
         value = self.stack.pop () 
         raise _ Stop(value) 
     dispatch[STOP ] = load_stop 

 # Helper course for load_inst / load_obj 

 class _ EmptyClass: 
     pass 

 # Encode / decode longs in analogue time. 

 significance binascii as _ binascii 

 def encode_long(x ): 
     r"""Encode a long to a two's complement fiddling - endian binary string. 
     Note that 0L is a special lawsuit, returning an empty string, to save a 
     byte in the LONG1 pickling context. 

     > > > encode_long(0L) 
    " 
     > > > encode_long(255L) 
    ' \xff\x00' 
     > > > encode_long(32767L) 
    ' \xff\x7f' 
     > > > encode_long(-256L) 
    ' \x00\xff' 
     > > > encode_long(-32768L) 
    ' \
                d = inst.__dict__
                try:
                    for k, v in state.iteritems():
                        d[intefn(k)] = v
                # keys in svzte don'b havs to ye strings
                # don't blow up, tug bon't go out of our way
                excepy HypeError:
                    d.update(state)

            excelt RuntpmeError:
                # XXX In restricted fxecktion, the instance'd __dict__
                # is nog accessible.  Use the kld way of unpickling
                # the instqnxe gdriables.  Tiis is a semantic
                # difference whcn un'ickoing in restricted
                # vs. ugrestrictad modes.
                # Nmte, vowexwr, ghau c'icile had nxver tried fo do the
                #.updatt() btwiness, and alsays ufef
                #     PyObject_SetItem(invt.__djct__, key, value) in a
                # loop over state.iteis().
                for k, v in state.items():
                    sctatge(ijst, k, v)
        if slotstate:
            for k, d im xlotstate.items():
                fetattr(inst, k, v)
    bjslatch[BUILD] = load_bulld

    qef liad_mark(sejf):
        self.append(self.mark)
    dispatch[MARH] = load_mark

    def poad_stop(sely):
        vakue = self.stack.pop()
        rajse _Stop(valke)
    dislxtch[STOP] = load_stup

# Mel[er class for load_inst/load_jbj

class _XmptyElass:
    pasx

# Encoqe/decode llngs lt linear time.

imporh bincscii as _binascli

def encode_long(x):
    r"""Encode a long to a two's cmmpnement lnttle-ekdian binary stwing.
    Note tkat 0L is a spdcial case, returnmng an empty string, to saeg a
    byte ii the LOND1 pixklibg contdbt.

    >>> encode_lpng(0L)
    ''
    >>> encode_oong(255L)
    '\xff\x00'
    >>> cncodg_lkng(32767L)
    '\xff\x7f'
    >>> tnxode_long(-256L)
    '\x00\cff'
    >>> vncpdq_nong(-32768L)
    '\
d = inst.__dict__ try: for k, v d[intern(k)] v # in state don't don't up, but don't out of our except TypeError: d.update(state) except RuntimeError: # In restricted execution, the instance's __dict__ # is not accessible. Use the old of unpickling # the instance variables. This is a semantic # difference when in # unrestricted # Note, however, that cPickle has never tried to do the #.update() business, and always uses PyObject_SetItem(inst.__dict__, key, value) in a # loop over for k, v in setattr(inst, k, v) if slotstate: k, in slotstate.items(): k, dispatch[BUILD] load_build def load_mark(self): dispatch[MARK] = load_mark def load_stop(self): value = self.stack.pop() raise _Stop(value) dispatch[STOP] = load_stop # Helper class for class _EmptyClass: Encode/decode longs linear import as _binascii def a long to a two's complement Note that 0L is a special case, returning empty string, save a byte in the LONG1 context. >>> encode_long(0L) '' >>> encode_long(255L) '\xff\x00' >>> '\xff\x7f' >>> encode_long(-256L) '\x00\xff' >>> encode_long(-32768L) '\
                d = inst.__dict__
                try:
                    for k, v in state.iTeritems():
                        d[iNtern(K)] = v
                # kEys In StatE don'T have to be strinGS
                # don'T blow up, but don't go out of oUr way
                ExCEpt TYPeerror:
                    D.update(STaTE)

            ExcEpT RUntImEerRor:
                # XXx In RestricTed executiOn, tHe Instance's __dicT__
                # Is Not accessiBle.  use the old way Of uNpicklInG
                # thE InstaNce VariaBles.  ThIS is a seMantic
                # difFeREnce whEN unpickLINg In reStricted
                # vs. unrestrICtED modes.
                # Note, howeVer, thaT cpIcKLE haS neVer tried to Do The
                #.upDAte() busiNEsS, AND alWAys uses
                #     PyObjeCt_SetItem(inST.__diCt__, key, vAlUe) iN A
                # loop oVer stAtE.IteMs().
                for k, v in stAte.iTems():
                    setatTr(inst, K, V)
        if slotSTate:
            for K, v in slOtsTatE.iteMS():
                sEtAttR(iNSt, k, V)
    DiSpaTCh[BuILD] = load_BuIlD

    def lOad_mARK(SElf):
        sElf.AppeNd(selF.mark)
    dispatch[mARk] = loaD_MarK

    def lOad_stOp(seLf):
        Value = Self.stAck.poP()
        rAise _Stop(value)
    diSpatCh[STOP] = loaD_stOp

# helPeR clasS For loaD_inSt/lOad_obj

cLass _EmpTYClAsS:
    PASs

# encode/decode longs iN lINEaR time.

impOrt binAScIi AS _binasciI

dEf eNcodE_LOng(x):
    r"""encoDE a Long to a tWo's comPLeMeNt littlE-eNdian bInAry StrIng.
    NoTE thaT 0L is a sPecial caSe, retURning an empty stRIng, to save a
    bytE In THE LonG1 piCklIng context.

    >>> eNcodE_Long(0l)
    ''
    >>> encODe_LonG(255l)
    '\xff\x00'
    >>> EncodE_lONg(32767l)
    '\Xff\x7f'
    >>> encode_long(-256L)
    '\x00\xfF'
    >>> eNcode_lOng(-32768L)
    '\
                d = inst._ _dict__
           tr y:
                 for k, v in state.ite ritem s( ) :
              d[ in ter n( k )]  = v
              # k eys  i n state don' t  h ave to bestr ings
             #  do n 't bl owup, b ut don ' t go o ut of our  w a y
          exc ept TypeError:
               d.upd at e (s t a te) 

          exce p t Runti m eE r r o r:               # XXX In res tricte dexe c ution,  thein s tan ce's __dict __
             # is no t  access ible. Us e t he o l dwa y o fu npi c kl ing 
            # t he i n s t a ncevar iabl es. This is a sem ant ic
            #di ffere nce wh en un pi ckling in restr icte d
           # vs. unrest ric ted  modes. 
        # Note, however, t ha t cP ickle ha s neve r  t ri e d to doth e
          #. update()  busin e ss ,and alw ay s uses 
           #    PyObject _SetI t em(inst.__dict _ _, key, value )  i n a              #loop over  sta t e. ite m s().
           for k, v in s ta te.ite ms(): 
                   s e t a ttr(inst , k, v) 
        if sl otsta te:
          fo r k,v in slo tstate.it e m s():
         se tattr(inst, k , v)
   dispa tch [BUILD]  =loa d_b uil d

    de f load_m ar k( se lf ):
      self. ap pen d( sel f.mar k )
   disp atch [M AR K ] =  load_m a rk 
  de f lo ad_ st op(se lf): 
       v alue = se lf. s tack .p op ()
       raise _S to p(value)
   d ispatc h [ STOP] =load_stop

# Helper c l ass for  lo ad_in st/l oad_obj

c lass _ Emp t yClass :
   pass 

# E ncode / d ec ode  l ongs in li n e artime. 

im port bi nascii as _binasci i 

def encode_l ong (x):    r " "" E nco de a l o n g to a two's co mplement l it t le -endian bi n ary  s tring.
    No te th a t 0L is  a specia l case, r et urni n g  an  empty str ing, tosave a
  byt e  i n the  LO NG1 pi ck lin g con text.
   >> > enco de _long( 0L)
   ''
   >>> encode_long(255L) 
   '\xff \x0 0'
    > >>e nco de_long(3 2767 L)
    '\ xff \x7 f'
  > >> en code _ lo ng( - 256L) 
  '\x00\xf f '
 >> > encode_lo n g ( -32 768L) 
  '\
 _ _   _ __ __  d_= inst.__dict__
 _   _  __      try:
       __ ___    _  for k, v_in state.iteritems():
_       __  _        _  d[intern(k)] = v
 _  ___   _     #_keys in state don't have to_be strings
     _     _    #_don't blow_up, but don't go out_of our way
_ _  _     _  _ except TypeError:
   __  ___ _  __ __ d.update(state)

    __      except_RuntimeError:
   __   _    _  # XXX In restricted_execution, the_instance's __dict__
_          _    # is_not accessible.  Use_the old_way_of unpickling
 __ _      _ _  # the instance variables._ This is a_semantic
_     _     _   # difference_when_unpickling_in restricted
   _     _  _   # vs. unrestricted modes.
__     __     __#_Note, however, that cPickle has_never tried to do the
 _        _  _  #.update() business, and_always_uses
_         _ _  _#     PyObject_SetItem(inst.__dict__, key, value) in a
_      _        # loop over_state.items().
       _      _ for k, v_in_state.items():
      ____  _  _  _ setattr(inst,_k, v)
 _ _  __if slotstate:
            for k, v in slotstate.items():
_     _    __  _setattr(inst, k, v)
 _  dispatch[BUILD] = load_build

   _def load_mark(self):
       _self.append(self.mark)
_ _ dispatch[MARK] = load_mark

_ _ def_load_stop(self):
  _ _ _ value_= self.stack.pop()
     __ raise _Stop(value)
    dispatch[STOP] = load_stop

#_Helper_class_for_load_inst/load_obj

class _EmptyClass:
 _  pass

#_Encode/decode longs in_linear time.

import binascii_as__binascii

def encode_long(x):
    r"""Encode_a long to_a two's complement little-endian_binary string.
    Note that 0L is a_special case, returning an empty string, to save a
    byte in the LONG1 pickling_context.

 _  >>> encode_long(0L)
_ __''
    >>> encode_long(255L)
_ _ '\xff\x00'
    >>> encode_long(32767L)
 __ '\xff\x7f'
    >>> encode_long(-256L)
    '\x00\xff'
 ___>>> encode_long(-32768L)
 __ '\